chore(napi-derive): allow unsafe async &mut self (#1453)

This commit is contained in:
LongYinan 2023-01-24 20:41:57 +08:00 committed by GitHub
parent e3adf5dac4
commit ab81f4126b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,10 +30,10 @@ impl TryToTokens for NapiFn {
.collect(),
);
}
if Some(FnSelf::MutRef) == self.fn_self && self.is_async {
if Some(FnSelf::MutRef) == self.fn_self && self.is_async && !self.unsafe_ {
return Err(Diagnostic::span_error(
self.name.span(),
"&mut self is incompatible with async napi methods",
"&mut self in async napi methods should be marked as unsafe",
));
}
let arg_ref_count = refs.len();