Merge pull request #1080 from messense/clippy
chore: fix `clippy::needless_late_init` lint
This commit is contained in:
commit
7626452cbf
2 changed files with 23 additions and 27 deletions
|
@ -326,12 +326,12 @@ fn replace_napi_attr_in_mod(
|
|||
#[napi(namespace = #js_namespace)]
|
||||
)
|
||||
};
|
||||
let struct_opts: BindgenAttrs;
|
||||
if let Some(TokenTree::Group(g)) = new_attr.tokens.into_iter().next() {
|
||||
struct_opts = syn::parse2(g.stream()).ok()?;
|
||||
} else {
|
||||
struct_opts = syn::parse2(quote! {}).ok()?;
|
||||
}
|
||||
let struct_opts: BindgenAttrs =
|
||||
if let Some(TokenTree::Group(g)) = new_attr.tokens.into_iter().next() {
|
||||
syn::parse2(g.stream()).ok()?
|
||||
} else {
|
||||
syn::parse2(quote! {}).ok()?
|
||||
};
|
||||
attrs.remove(index);
|
||||
Some(struct_opts)
|
||||
} else {
|
||||
|
|
|
@ -373,12 +373,10 @@ unsafe extern "C" fn call_js_cb<T: 'static, V: NapiRaw, R, ES>(
|
|||
})
|
||||
});
|
||||
|
||||
let status;
|
||||
|
||||
// Follow async callback conventions: https://nodejs.org/en/knowledge/errors/what-are-the-error-conventions/
|
||||
// Check if the Result is okay, if so, pass a null as the first (error) argument automatically.
|
||||
// If the Result is an error, pass that as the first argument.
|
||||
match ret {
|
||||
let status = match ret {
|
||||
Ok(values) => {
|
||||
let values = values.iter().map(|v| unsafe { v.raw() });
|
||||
let args: Vec<sys::napi_value> = if ES::VALUE == ErrorStrategy::CalleeHandled::VALUE {
|
||||
|
@ -388,7 +386,7 @@ unsafe extern "C" fn call_js_cb<T: 'static, V: NapiRaw, R, ES>(
|
|||
} else {
|
||||
values.collect()
|
||||
};
|
||||
status = unsafe {
|
||||
unsafe {
|
||||
sys::napi_call_function(
|
||||
raw_env,
|
||||
recv,
|
||||
|
@ -397,24 +395,22 @@ unsafe extern "C" fn call_js_cb<T: 'static, V: NapiRaw, R, ES>(
|
|||
args.as_ptr(),
|
||||
ptr::null_mut(),
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(e) if ES::VALUE == ErrorStrategy::Fatal::VALUE => {
|
||||
status = unsafe { sys::napi_fatal_exception(raw_env, JsError::from(e).into_value(raw_env)) };
|
||||
}
|
||||
Err(e) => {
|
||||
status = unsafe {
|
||||
sys::napi_call_function(
|
||||
raw_env,
|
||||
recv,
|
||||
js_callback,
|
||||
1,
|
||||
[JsError::from(e).into_value(raw_env)].as_mut_ptr(),
|
||||
ptr::null_mut(),
|
||||
)
|
||||
};
|
||||
}
|
||||
}
|
||||
Err(e) if ES::VALUE == ErrorStrategy::Fatal::VALUE => unsafe {
|
||||
sys::napi_fatal_exception(raw_env, JsError::from(e).into_value(raw_env))
|
||||
},
|
||||
Err(e) => unsafe {
|
||||
sys::napi_call_function(
|
||||
raw_env,
|
||||
recv,
|
||||
js_callback,
|
||||
1,
|
||||
[JsError::from(e).into_value(raw_env)].as_mut_ptr(),
|
||||
ptr::null_mut(),
|
||||
)
|
||||
},
|
||||
};
|
||||
if status == sys::Status::napi_ok {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue