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)]
|
#[napi(namespace = #js_namespace)]
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let struct_opts: BindgenAttrs;
|
let struct_opts: BindgenAttrs =
|
||||||
if let Some(TokenTree::Group(g)) = new_attr.tokens.into_iter().next() {
|
if let Some(TokenTree::Group(g)) = new_attr.tokens.into_iter().next() {
|
||||||
struct_opts = syn::parse2(g.stream()).ok()?;
|
syn::parse2(g.stream()).ok()?
|
||||||
} else {
|
} else {
|
||||||
struct_opts = syn::parse2(quote! {}).ok()?;
|
syn::parse2(quote! {}).ok()?
|
||||||
}
|
};
|
||||||
attrs.remove(index);
|
attrs.remove(index);
|
||||||
Some(struct_opts)
|
Some(struct_opts)
|
||||||
} else {
|
} 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/
|
// 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.
|
// 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.
|
// If the Result is an error, pass that as the first argument.
|
||||||
match ret {
|
let status = match ret {
|
||||||
Ok(values) => {
|
Ok(values) => {
|
||||||
let values = values.iter().map(|v| unsafe { v.raw() });
|
let values = values.iter().map(|v| unsafe { v.raw() });
|
||||||
let args: Vec<sys::napi_value> = if ES::VALUE == ErrorStrategy::CalleeHandled::VALUE {
|
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 {
|
} else {
|
||||||
values.collect()
|
values.collect()
|
||||||
};
|
};
|
||||||
status = unsafe {
|
unsafe {
|
||||||
sys::napi_call_function(
|
sys::napi_call_function(
|
||||||
raw_env,
|
raw_env,
|
||||||
recv,
|
recv,
|
||||||
|
@ -397,24 +395,22 @@ unsafe extern "C" fn call_js_cb<T: 'static, V: NapiRaw, R, ES>(
|
||||||
args.as_ptr(),
|
args.as_ptr(),
|
||||||
ptr::null_mut(),
|
ptr::null_mut(),
|
||||||
)
|
)
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
Err(e) if ES::VALUE == ErrorStrategy::Fatal::VALUE => {
|
Err(e) if ES::VALUE == ErrorStrategy::Fatal::VALUE => unsafe {
|
||||||
status = unsafe { sys::napi_fatal_exception(raw_env, JsError::from(e).into_value(raw_env)) };
|
sys::napi_fatal_exception(raw_env, JsError::from(e).into_value(raw_env))
|
||||||
}
|
},
|
||||||
Err(e) => {
|
Err(e) => unsafe {
|
||||||
status = unsafe {
|
sys::napi_call_function(
|
||||||
sys::napi_call_function(
|
raw_env,
|
||||||
raw_env,
|
recv,
|
||||||
recv,
|
js_callback,
|
||||||
js_callback,
|
1,
|
||||||
1,
|
[JsError::from(e).into_value(raw_env)].as_mut_ptr(),
|
||||||
[JsError::from(e).into_value(raw_env)].as_mut_ptr(),
|
ptr::null_mut(),
|
||||||
ptr::null_mut(),
|
)
|
||||||
)
|
},
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
if status == sys::Status::napi_ok {
|
if status == sys::Status::napi_ok {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue