diff options
author | 林炳权 <695601626@qq.com> | 2023-08-27 12:04:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-26 22:04:12 -0600 |
commit | 2080669943e79aba619bc80829172c696ec1f15c (patch) | |
tree | 9eb317754a9632220abb3df238a30375164d705a /cli/napi | |
parent | e4cebf3e0da539321727b0f0e43ddce5679635b1 (diff) |
chore: update to Rust 1.72 (#20258)
<!--
Before submitting a PR, please read https://deno.com/manual/contributing
1. Give the PR a descriptive title.
Examples of good title:
- fix(std/http): Fix race condition in server
- docs(console): Update docstrings
- feat(doc): Handle nested reexports
Examples of bad title:
- fix #7123
- update docs
- fix bugs
2. Ensure there is a related issue and it is referenced in the PR text.
3. Ensure there are tests that cover the changes.
4. Ensure `cargo test` passes.
5. Ensure `./tools/format.js` passes without changing files.
6. Ensure `./tools/lint.js` passes.
7. Open as a draft PR if your work is still in progress. The CI won't
run
all steps, but you can add '[ci]' to a commit message to force it to.
8. If you would like to run the benchmarks on the CI, add the 'ci-bench'
label.
-->
As the title.
---------
Co-authored-by: Matt Mastracci <matthew@mastracci.com>
Diffstat (limited to 'cli/napi')
-rw-r--r-- | cli/napi/js_native_api.rs | 77 |
1 files changed, 32 insertions, 45 deletions
diff --git a/cli/napi/js_native_api.rs b/cli/napi/js_native_api.rs index cb31d8c63..7c9b3d4c7 100644 --- a/cli/napi/js_native_api.rs +++ b/cli/napi/js_native_api.rs @@ -308,10 +308,9 @@ fn napi_coerce_to_number( check_env!(env); let env = unsafe { &mut *env }; let value = napi_value_unchecked(value); - let Some(coerced) = value - .to_number(&mut env.scope()) else { - return napi_number_expected; - }; + let Some(coerced) = value.to_number(&mut env.scope()) else { + return napi_number_expected; + }; let value: v8::Local<v8::Value> = coerced.into(); *result = value.into(); napi_ok @@ -1352,10 +1351,9 @@ fn napi_call_function( #[napi_sym::napi_sym] fn napi_close_escapable_handle_scope( - env: *mut Env, + _env: *mut Env, _scope: napi_escapable_handle_scope, ) -> napi_status { - let mut _env = &mut *(env as *mut Env); // TODO: do this properly napi_ok } @@ -1365,7 +1363,7 @@ fn napi_close_handle_scope( env: *mut Env, scope: napi_handle_scope, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; if env.open_handle_scopes == 0 { return napi_handle_scope_mismatch; } @@ -1497,7 +1495,7 @@ fn napi_define_class( env_ptr, *result, static_descriptors.len(), - static_descriptors.as_ptr() as *const napi_property_descriptor, + static_descriptors.as_ptr(), )); } @@ -1519,7 +1517,8 @@ fn napi_define_properties( let scope = &mut env.scope(); - let Ok(object) = v8::Local::<v8::Object>::try_from(napi_value_unchecked(obj)) else { + let Ok(object) = v8::Local::<v8::Object>::try_from(napi_value_unchecked(obj)) + else { return napi_object_expected; }; @@ -1614,11 +1613,9 @@ fn napi_delete_property( check_arg!(env, result); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg; - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; let Some(deleted) = object.delete(scope, key.unwrap_unchecked()) else { return napi_generic_failure; @@ -1630,8 +1627,7 @@ fn napi_delete_property( // TODO: properly implement ref counting stuff #[napi_sym::napi_sym] -fn napi_delete_reference(env: *mut Env, _nref: napi_ref) -> napi_status { - let mut _env = &mut *(env as *mut Env); +fn napi_delete_reference(_env: *mut Env, _nref: napi_ref) -> napi_status { napi_ok } @@ -1869,7 +1865,7 @@ fn napi_get_instance_data( env: *mut Env, result: *mut *mut c_void, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; let shared = env.shared(); *result = shared.instance_data; napi_ok @@ -2118,11 +2114,9 @@ fn napi_has_own_property( check_arg!(env, result); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg; - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; if key.is_none() { return napi_invalid_arg; @@ -2131,7 +2125,7 @@ fn napi_has_own_property( return napi_name_expected; }; - let Some(has_own) = object.has_own_property(scope, key) else { + let Some(has_own) = object.has_own_property(scope, key) else { return napi_generic_failure; }; @@ -2153,11 +2147,9 @@ fn napi_has_property( check_arg!(env, result); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg; - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; let Some(has) = object.has(scope, key.unwrap_unchecked()) else { return napi_generic_failure; @@ -2180,10 +2172,9 @@ fn napi_instanceof( let value = napi_value_unchecked(value); let constructor = napi_value_unchecked(constructor); - let Some(ctor) = constructor - .to_object(&mut env.scope()) else { - return napi_object_expected; - }; + let Some(ctor) = constructor.to_object(&mut env.scope()) else { + return napi_object_expected; + }; if !ctor.is_function() { return napi_function_expected; } @@ -2294,8 +2285,7 @@ fn napi_is_error( } #[napi_sym::napi_sym] -fn napi_is_exception_pending(env: *mut Env, result: *mut bool) -> napi_status { - let mut _env = &mut *(env as *mut Env); +fn napi_is_exception_pending(_env: *mut Env, result: *mut bool) -> napi_status { // TODO *result = false; napi_ok @@ -2389,7 +2379,7 @@ fn napi_open_handle_scope( env: *mut Env, _result: *mut napi_handle_scope, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; // *result = &mut env.scope() as *mut _ as napi_handle_scope; env.open_handle_scopes += 1; @@ -2525,7 +2515,7 @@ fn napi_set_instance_data( finalize_cb: Option<napi_finalize>, finalize_hint: *mut c_void, ) -> napi_status { - let env = &mut *(env as *mut Env); + let env = &mut *env; let shared = env.shared_mut(); shared.instance_data = data; shared.data_finalize = if finalize_cb.is_some() { @@ -2567,11 +2557,9 @@ fn napi_set_property( check_arg_option!(env, value); let scope = &mut env.scope(); - let Some(object) = object - .map(|o| o.to_object(scope)) - .flatten() else { - return napi_invalid_arg - }; + let Some(object) = object.map(|o| o.to_object(scope)).flatten() else { + return napi_invalid_arg; + }; if object .set(scope, key.unwrap_unchecked(), value.unwrap_unchecked()) @@ -2759,10 +2747,9 @@ fn napi_unwrap( let shared = &*(env.shared as *const EnvShared); let napi_wrap = v8::Local::new(&mut env.scope(), &shared.napi_wrap); let ext = obj.get_private(&mut env.scope(), napi_wrap).unwrap(); - let Some(ext) = v8::Local::<v8::External>::try_from(ext) - .ok() else { - return napi_invalid_arg; - }; + let Some(ext) = v8::Local::<v8::External>::try_from(ext).ok() else { + return napi_invalid_arg; + }; *result = ext.value(); napi_ok } |