diff --git a/build.rs b/build.rs index f9e3dbf94f..3f6ab13e25 100644 --- a/build.rs +++ b/build.rs @@ -216,7 +216,7 @@ fn build_v8() { fn print_gn_args(gn_out_dir: &Path) { assert!(Command::new(gn()) .arg("args") - .arg(&gn_out_dir) + .arg(gn_out_dir) .arg("--list") .status() .unwrap() @@ -643,7 +643,7 @@ fn ninja(gn_out_dir: &Path, maybe_env: Option) -> Command { let cmd_string = env::var("NINJA").unwrap_or_else(|_| "ninja".to_owned()); let mut cmd = Command::new(cmd_string); cmd.arg("-C"); - cmd.arg(&gn_out_dir); + cmd.arg(gn_out_dir); if let Some(env) = maybe_env { for item in env { cmd.env(item.0, item.1); diff --git a/examples/shell.rs b/examples/shell.rs index 50fd598192..d01800e5f8 100644 --- a/examples/shell.rs +++ b/examples/shell.rs @@ -17,7 +17,7 @@ fn main() { let context_scope = &mut v8::ContextScope::new(handle_scope, context); let scope = &mut v8::HandleScope::new(context_scope); - run_main(scope, &*args, &mut run_shell_flag); + run_main(scope, &args, &mut run_shell_flag); if run_shell_flag { run_shell(scope); diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 4d5fde5bd1..0000000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.60.0 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000000..c032b57308 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.65.0" +components = ["rustfmt", "clippy"] diff --git a/src/bigint.rs b/src/bigint.rs index 9ebe842b58..bc68e3c968 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -85,7 +85,7 @@ impl BigInt { #[inline(always)] pub fn u64_value(&self) -> (u64, bool) { let mut lossless = MaybeUninit::uninit(); - let v = unsafe { v8__BigInt__Uint64Value(&*self, lossless.as_mut_ptr()) }; + let v = unsafe { v8__BigInt__Uint64Value(self, lossless.as_mut_ptr()) }; let lossless = unsafe { lossless.assume_init() }; (v, lossless) } @@ -95,7 +95,7 @@ impl BigInt { #[inline(always)] pub fn i64_value(&self) -> (i64, bool) { let mut lossless = MaybeUninit::uninit(); - let v = unsafe { v8__BigInt__Int64Value(&*self, lossless.as_mut_ptr()) }; + let v = unsafe { v8__BigInt__Int64Value(self, lossless.as_mut_ptr()) }; let lossless = unsafe { lossless.assume_init() }; (v, lossless) } @@ -104,7 +104,7 @@ impl BigInt { /// `to_words_array`. #[inline(always)] pub fn word_count(&self) -> usize { - unsafe { v8__BigInt__WordCount(&*self) as usize } + unsafe { v8__BigInt__WordCount(self) as usize } } /// Converts this BigInt to a (sign_bit, words) pair. `sign_bit` will be true @@ -119,7 +119,7 @@ impl BigInt { let mut word_count = words.len() as int; unsafe { v8__BigInt__ToWordsArray( - &*self, + self, sign_bit.as_mut_ptr(), &mut word_count, words.as_mut_ptr(), diff --git a/src/external_references.rs b/src/external_references.rs index 2960968f95..24a9c2abcf 100644 --- a/src/external_references.rs +++ b/src/external_references.rs @@ -40,12 +40,12 @@ impl ExternalReferences { impl std::ops::Deref for ExternalReferences { type Target = [intptr_t]; fn deref(&self) -> &Self::Target { - &*self.null_terminated + &self.null_terminated } } impl std::borrow::Borrow<[intptr_t]> for ExternalReferences { fn borrow(&self) -> &[intptr_t] { - &**self + self } } diff --git a/src/fast_api.rs b/src/fast_api.rs index 159ad584ac..3ca7bbaf1c 100644 --- a/src/fast_api.rs +++ b/src/fast_api.rs @@ -65,7 +65,7 @@ impl CTypeInfo { } } -#[derive(Clone, Copy, PartialEq, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Debug)] #[repr(u8)] pub enum SequenceType { Scalar, diff --git a/src/function.rs b/src/function.rs index b8cc776972..61bb35ae88 100644 --- a/src/function.rs +++ b/src/function.rs @@ -810,14 +810,14 @@ impl Function { #[inline(always)] pub fn get_script_column_number(&self) -> Option { let ret = unsafe { v8__Function__GetScriptColumnNumber(self) }; - (ret >= 0).then(|| ret as u32) + (ret >= 0).then_some(ret as u32) } /// Get the (zero-indexed) line number of the function's definition, if available. #[inline(always)] pub fn get_script_line_number(&self) -> Option { let ret = unsafe { v8__Function__GetScriptLineNumber(self) }; - (ret >= 0).then(|| ret as u32) + (ret >= 0).then_some(ret as u32) } /// Creates and returns code cache for the specified unbound_script. diff --git a/src/handle.rs b/src/handle.rs index b6c982ab89..bbf245d2b4 100644 --- a/src/handle.rs +++ b/src/handle.rs @@ -350,7 +350,7 @@ impl<'a, T> Handle for &'a UnsafeRefHandle<'_, T> { impl<'s, T> Borrow for Local<'s, T> { fn borrow(&self) -> &T { - &**self + self } } @@ -369,7 +369,7 @@ impl Eq for Global where T: Eq {} impl<'s, T: Hash> Hash for Local<'s, T> { fn hash(&self, state: &mut H) { - (&**self).hash(state) + (**self).hash(state) } } @@ -396,7 +396,7 @@ where } } -impl<'s, T, Rhs: Handle> PartialEq for Global +impl PartialEq for Global where T: PartialEq, { diff --git a/src/inspector.rs b/src/inspector.rs index b56c8839b2..0af58bc1a4 100644 --- a/src/inspector.rs +++ b/src/inspector.rs @@ -822,7 +822,7 @@ impl fmt::Display for CharacterArray<'_, u8> { impl fmt::Display for CharacterArray<'_, u16> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.write_str(&string::String::from_utf16_lossy(&*self)) + f.write_str(&string::String::from_utf16_lossy(self)) } } diff --git a/src/isolate.rs b/src/isolate.rs index e63ea9e8d8..be4f776d5d 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -62,7 +62,7 @@ use std::sync::Mutex; /// Isolate::PerformMicrotaskCheckpoint() method; /// - auto: microtasks are invoked when the script call depth decrements /// to zero. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(C)] pub enum MicrotasksPolicy { Explicit = 0, @@ -84,7 +84,7 @@ pub enum MicrotasksPolicy { /// /// PromiseHook with type After is called right at the end of the /// PromiseReactionJob. -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(C)] pub enum PromiseHookType { Init, @@ -100,7 +100,7 @@ pub type PromiseHook = pub type PromiseRejectCallback = extern "C" fn(PromiseRejectMessage); -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(C)] pub enum WasmAsyncSuccess { Success, diff --git a/src/module.rs b/src/module.rs index e8c8c4e3f5..c6231b960f 100644 --- a/src/module.rs +++ b/src/module.rs @@ -230,7 +230,7 @@ impl Location { /// This corresponds to the states used in ECMAScript except that "evaluated" /// is split into kEvaluated and kErrored, indicating success and failure, /// respectively. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] #[repr(C)] pub enum ModuleStatus { Uninstantiated, @@ -345,20 +345,20 @@ impl Module { ) -> Option> { unsafe { scope - .cast_local(|sd| v8__Module__Evaluate(&*self, sd.get_current_context())) + .cast_local(|sd| v8__Module__Evaluate(self, sd.get_current_context())) } } /// Returns whether the module is a SourceTextModule. #[inline(always)] pub fn is_source_text_module(&self) -> bool { - unsafe { v8__Module__IsSourceTextModule(&*self) } + unsafe { v8__Module__IsSourceTextModule(self) } } /// Returns whether the module is a SyntheticModule. #[inline(always)] pub fn is_synthetic_module(&self) -> bool { - unsafe { v8__Module__IsSyntheticModule(&*self) } + unsafe { v8__Module__IsSyntheticModule(self) } } /// Creates a new SyntheticModule with the specified export names, where @@ -406,7 +406,7 @@ impl Module { ) -> Option { unsafe { v8__Module__SetSyntheticModuleExport( - &*self, + self, scope.get_isolate_ptr(), &*export_name, &*export_value, @@ -446,7 +446,7 @@ impl Module { let returned_len = unsafe { v8__Module__GetStalledTopLevelAwaitMessage( - &*self, + self, scope.get_isolate_ptr(), out_vec.as_mut_ptr(), out_vec.len(), diff --git a/src/private.rs b/src/private.rs index bb20743bed..20d9896ef6 100644 --- a/src/private.rs +++ b/src/private.rs @@ -61,6 +61,6 @@ impl Private { /// Returns the print name string of the private symbol, or undefined if none. #[inline(always)] pub fn name<'s>(&self, scope: &mut HandleScope<'s, ()>) -> Local<'s, Value> { - unsafe { scope.cast_local(|_| v8__Private__Name(&*self)) }.unwrap() + unsafe { scope.cast_local(|_| v8__Private__Name(self)) }.unwrap() } } diff --git a/src/promise.rs b/src/promise.rs index e4d8c256cb..ece53e5410 100644 --- a/src/promise.rs +++ b/src/promise.rs @@ -57,7 +57,7 @@ extern "C" { ) -> PromiseRejectEvent; } -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] #[repr(C)] pub enum PromiseState { Pending, @@ -69,21 +69,21 @@ impl Promise { /// Returns the value of the [[PromiseState]] field. #[inline(always)] pub fn state(&self) -> PromiseState { - unsafe { v8__Promise__State(&*self) } + unsafe { v8__Promise__State(self) } } /// Returns true if the promise has at least one derived promise, and /// therefore resolve/reject handlers (including default handler). #[inline(always)] pub fn has_handler(&self) -> bool { - unsafe { v8__Promise__HasHandler(&*self) } + unsafe { v8__Promise__HasHandler(self) } } /// Returns the content of the [[PromiseResult]] field. The Promise must not /// be pending. #[inline(always)] pub fn result<'s>(&self, scope: &mut HandleScope<'s>) -> Local<'s, Value> { - unsafe { scope.cast_local(|_| v8__Promise__Result(&*self)) }.unwrap() + unsafe { scope.cast_local(|_| v8__Promise__Result(self)) }.unwrap() } /// Register a rejection handler with a promise. @@ -97,7 +97,7 @@ impl Promise { ) -> Option> { unsafe { scope.cast_local(|sd| { - v8__Promise__Catch(&*self, sd.get_current_context(), &*handler) + v8__Promise__Catch(self, sd.get_current_context(), &*handler) }) } } @@ -113,7 +113,7 @@ impl Promise { ) -> Option> { unsafe { scope.cast_local(|sd| { - v8__Promise__Then(&*self, sd.get_current_context(), &*handler) + v8__Promise__Then(self, sd.get_current_context(), &*handler) }) } } @@ -132,7 +132,7 @@ impl Promise { unsafe { scope.cast_local(|sd| { v8__Promise__Then2( - &*self, + self, sd.get_current_context(), &*on_fulfilled, &*on_rejected, @@ -160,7 +160,7 @@ impl PromiseResolver { &self, scope: &mut HandleScope<'s>, ) -> Local<'s, Promise> { - unsafe { scope.cast_local(|_| v8__Promise__Resolver__GetPromise(&*self)) } + unsafe { scope.cast_local(|_| v8__Promise__Resolver__GetPromise(self)) } .unwrap() } @@ -174,7 +174,7 @@ impl PromiseResolver { ) -> Option { unsafe { v8__Promise__Resolver__Resolve( - &*self, + self, &*scope.get_current_context(), &*value, ) @@ -192,7 +192,7 @@ impl PromiseResolver { ) -> Option { unsafe { v8__Promise__Resolver__Reject( - &*self, + self, &*scope.get_current_context(), &*value, ) @@ -201,7 +201,7 @@ impl PromiseResolver { } } -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[repr(C)] pub enum PromiseRejectEvent { PromiseRejectWithNoHandler, diff --git a/src/proxy.rs b/src/proxy.rs index f3834d342a..519b031a37 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -36,7 +36,7 @@ impl Proxy { &self, scope: &mut HandleScope<'s>, ) -> Local<'s, Value> { - unsafe { scope.cast_local(|_| v8__Proxy__GetHandler(&*self)) }.unwrap() + unsafe { scope.cast_local(|_| v8__Proxy__GetHandler(self)) }.unwrap() } #[inline(always)] @@ -44,7 +44,7 @@ impl Proxy { &self, scope: &mut HandleScope<'s>, ) -> Local<'s, Value> { - unsafe { scope.cast_local(|_| v8__Proxy__GetTarget(&*self)) }.unwrap() + unsafe { scope.cast_local(|_| v8__Proxy__GetTarget(self)) }.unwrap() } #[inline(always)] diff --git a/src/snapshot.rs b/src/snapshot.rs index eb0928b899..e1eb771e6d 100644 --- a/src/snapshot.rs +++ b/src/snapshot.rs @@ -78,13 +78,13 @@ impl Deref for StartupData { impl AsRef<[u8]> for StartupData { fn as_ref(&self) -> &[u8] { - &**self + self } } impl Borrow<[u8]> for StartupData { fn borrow(&self) -> &[u8] { - &**self + self } } diff --git a/src/support.rs b/src/support.rs index e28920c071..9eef944c2e 100644 --- a/src/support.rs +++ b/src/support.rs @@ -152,25 +152,25 @@ impl DerefMut for UniqueRef { impl AsRef for UniqueRef { fn as_ref(&self) -> &T { - &**self + self } } impl AsMut for UniqueRef { fn as_mut(&mut self) -> &mut T { - &mut **self + self } } impl Borrow for UniqueRef { fn borrow(&self) -> &T { - &**self + self } } impl BorrowMut for UniqueRef { fn borrow_mut(&mut self) -> &mut T { - &mut **self + self } } @@ -324,13 +324,13 @@ impl Deref for SharedRef { impl AsRef for SharedRef { fn as_ref(&self) -> &T { - &**self + self } } impl Borrow for SharedRef { fn borrow(&self) -> &T { - &**self + self } } @@ -452,25 +452,25 @@ impl Deref for Allocation { Self::Box(v) => v.borrow(), Self::Rc(v) => v.borrow(), Self::UniqueRef(v) => v.borrow(), - Self::Other(v) => (&**v).borrow(), + Self::Other(v) => (**v).borrow(), } } } impl AsRef for Allocation { fn as_ref(&self) -> &T { - &**self + self } } impl Borrow for Allocation { fn borrow(&self) -> &T { - &**self + self } } #[repr(C)] -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum MaybeBool { JustFalse = 0, JustTrue = 1, @@ -855,7 +855,7 @@ mod tests { impl Borrow for TestObjRef { fn borrow(&self) -> &TestObj { - &**self + self } } diff --git a/src/symbol.rs b/src/symbol.rs index d876cf4dcd..42e0da83ee 100644 --- a/src/symbol.rs +++ b/src/symbol.rs @@ -77,8 +77,7 @@ impl Symbol { scope: &mut HandleScope<'s, ()>, ) -> Local<'s, Value> { unsafe { - scope - .cast_local(|sd| v8__Symbol__Description(&*self, sd.get_isolate_ptr())) + scope.cast_local(|sd| v8__Symbol__Description(self, sd.get_isolate_ptr())) } .unwrap() } diff --git a/src/value_deserializer.rs b/src/value_deserializer.rs index ee68d25191..00f3a9ad8e 100644 --- a/src/value_deserializer.rs +++ b/src/value_deserializer.rs @@ -346,7 +346,7 @@ impl<'a, 's> ValueDeserializerHelper for ValueDeserializerHeap<'a, 's> { impl<'a, 's> ValueDeserializerHelper for ValueDeserializer<'a, 's> { fn get_cxx_value_deserializer(&mut self) -> &mut CxxValueDeserializer { - &mut (*self.value_deserializer_heap).cxx_value_deserializer + &mut self.value_deserializer_heap.cxx_value_deserializer } } @@ -378,18 +378,20 @@ impl<'a, 's> ValueDeserializer<'a, 's> { }); unsafe { - v8__ValueDeserializer__Delegate__CONSTRUCT(core::mem::transmute( - &mut (*value_deserializer_heap).cxx_value_deserializer_delegate, - )); + v8__ValueDeserializer__Delegate__CONSTRUCT( + &mut value_deserializer_heap.cxx_value_deserializer_delegate + as *mut CxxValueDeserializerDelegate + as *mut std::mem::MaybeUninit, + ); v8__ValueDeserializer__CONSTRUCT( - core::mem::transmute( - &mut (*value_deserializer_heap).cxx_value_deserializer, - ), + &mut value_deserializer_heap.cxx_value_deserializer + as *mut CxxValueDeserializer + as *mut std::mem::MaybeUninit, scope.get_isolate_ptr(), data.as_ptr(), data.len(), - &mut (*value_deserializer_heap).cxx_value_deserializer_delegate, + &mut value_deserializer_heap.cxx_value_deserializer_delegate, ); }; @@ -406,7 +408,7 @@ impl<'a, 's> ValueDeserializer<'a, 's> { ) { unsafe { v8__ValueDeserializer__SetSupportsLegacyWireFormat( - &mut (*self.value_deserializer_heap).cxx_value_deserializer, + &mut self.value_deserializer_heap.cxx_value_deserializer, supports_legacy_wire_format, ); } @@ -416,6 +418,6 @@ impl<'a, 's> ValueDeserializer<'a, 's> { &mut self, context: Local<'t, Context>, ) -> Option> { - (*self.value_deserializer_heap).read_value(context) + self.value_deserializer_heap.read_value(context) } } diff --git a/src/value_serializer.rs b/src/value_serializer.rs index fa703b9b38..54a003c981 100644 --- a/src/value_serializer.rs +++ b/src/value_serializer.rs @@ -389,7 +389,7 @@ impl<'a, 's> ValueSerializerHelper for ValueSerializerHeap<'a, 's> { impl<'a, 's> ValueSerializerHelper for ValueSerializer<'a, 's> { fn get_cxx_value_serializer(&mut self) -> &mut CxxValueSerializer { - &mut (*self.value_serializer_heap).cxx_value_serializer + &mut self.value_serializer_heap.cxx_value_serializer } } @@ -421,16 +421,18 @@ impl<'a, 's> ValueSerializer<'a, 's> { }); unsafe { - v8__ValueSerializer__Delegate__CONSTRUCT(core::mem::transmute( - &mut (*value_serializer_heap).cxx_value_serializer_delegate, - )); + v8__ValueSerializer__Delegate__CONSTRUCT( + &mut value_serializer_heap.cxx_value_serializer_delegate + as *mut CxxValueSerializerDelegate + as *mut std::mem::MaybeUninit, + ); v8__ValueSerializer__CONSTRUCT( - core::mem::transmute( - &mut (*value_serializer_heap).cxx_value_serializer, - ), + &mut value_serializer_heap.cxx_value_serializer + as *mut CxxValueSerializer + as *mut std::mem::MaybeUninit, scope.get_isolate_ptr(), - &mut (*value_serializer_heap).cxx_value_serializer_delegate, + &mut value_serializer_heap.cxx_value_serializer_delegate, ); }; @@ -446,14 +448,14 @@ impl<'a, 's> ValueSerializer<'a, 's> { let mut size: usize = 0; let mut ptr: *mut u8 = &mut 0; v8__ValueSerializer__Release( - &mut (*self.value_serializer_heap).cxx_value_serializer, + &mut self.value_serializer_heap.cxx_value_serializer, &mut ptr, &mut size, ); Vec::from_raw_parts( ptr as *mut u8, size, - (*self.value_serializer_heap).buffer_size, + self.value_serializer_heap.buffer_size, ) } } @@ -463,6 +465,6 @@ impl<'a, 's> ValueSerializer<'a, 's> { context: Local, value: Local, ) -> Option { - (*self.value_serializer_heap).write_value(context, value) + self.value_serializer_heap.write_value(context, value) } } diff --git a/tests/compile_fail/handle_scope_escape_to_nowhere.stderr b/tests/compile_fail/handle_scope_escape_to_nowhere.stderr index 416f9f6593..7fe08661bf 100644 --- a/tests/compile_fail/handle_scope_escape_to_nowhere.stderr +++ b/tests/compile_fail/handle_scope_escape_to_nowhere.stderr @@ -6,14 +6,40 @@ error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandl | | | required by a bound introduced by this call | + = help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`: + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'e>> + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'e>> note: required by a bound in `EscapableHandleScope::<'s, 'e>::new` --> src/scope.rs | | pub fn new>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EscapableHandleScope::<'s, 'e>::new` +error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied + --> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:20 + | +5 | let mut _scope = v8::EscapableHandleScope::new(&mut isolate); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate` + | + = help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`: + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'e>> + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'e>> + error[E0277]: the trait bound `OwnedIsolate: v8::scope::param::NewEscapableHandleScope<'_, '_>` is not satisfied --> tests/compile_fail/handle_scope_escape_to_nowhere.rs:5:20 | 5 | let mut _scope = v8::EscapableHandleScope::new(&mut isolate); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `v8::scope::param::NewEscapableHandleScope<'_, '_>` is not implemented for `OwnedIsolate` + | + = help: the following other types implement trait `v8::scope::param::NewEscapableHandleScope<'s, 'e>`: + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'e>> + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'p>> + as v8::scope::param::NewEscapableHandleScope<'s, 'e>> diff --git a/tests/compile_fail/object_without_context_scope.stderr b/tests/compile_fail/object_without_context_scope.stderr index dcfb94a4b0..4e0b2bda23 100644 --- a/tests/compile_fail/object_without_context_scope.stderr +++ b/tests/compile_fail/object_without_context_scope.stderr @@ -1,8 +1,15 @@ error[E0308]: mismatched types - --> $DIR/object_without_context_scope.rs:6:33 - | -6 | let _object = v8::Object::new(&mut scope); - | ^^^^^^^^^^ expected struct `v8::Context`, found `()` - | - = note: expected mutable reference `&mut HandleScope<'_>` - found mutable reference `&mut HandleScope<'_, ()>` + --> tests/compile_fail/object_without_context_scope.rs:6:33 + | +6 | let _object = v8::Object::new(&mut scope); + | --------------- ^^^^^^^^^^ expected struct `v8::Context`, found `()` + | | + | arguments to this function are incorrect + | + = note: expected mutable reference `&mut HandleScope<'_>` + found mutable reference `&mut HandleScope<'_, ()>` +note: associated function defined here + --> src/object.rs + | + | pub fn new<'s>(scope: &mut HandleScope<'s>) -> Local<'s, Object> { + | ^^^ diff --git a/tests/test_api.rs b/tests/test_api.rs index b778e097a3..13ec5fe658 100644 --- a/tests/test_api.rs +++ b/tests/test_api.rs @@ -5770,7 +5770,9 @@ fn synthetic_evaluation_steps<'a>( let scope = &mut v8::TryCatch::new(scope); let name = v8::String::new(scope, "does not exist").unwrap(); let value = v8::undefined(scope).into(); - assert!(module.set_synthetic_module_export(scope, name, value) == None); + assert!(module + .set_synthetic_module_export(scope, name, value) + .is_none()); assert!(scope.has_caught()); scope.reset(); } @@ -6282,7 +6284,7 @@ impl<'a> Custom2Value { } } -impl<'a> v8::ValueSerializerImpl for Custom2Value { +impl v8::ValueSerializerImpl for Custom2Value { #[allow(unused_variables)] fn throw_data_clone_error<'s>( &mut self, @@ -6496,7 +6498,7 @@ fn run_with_rust_allocator() { } unsafe extern "C" fn free(count: &AtomicUsize, data: *mut c_void, n: usize) { count.fetch_sub(n, Ordering::SeqCst); - Box::from_raw(std::slice::from_raw_parts_mut(data as *mut u8, n)); + let _ = Box::from_raw(std::slice::from_raw_parts_mut(data as *mut u8, n)); } unsafe extern "C" fn reallocate( count: &AtomicUsize, @@ -7373,7 +7375,7 @@ fn weak_handle() { let scope = &mut v8::HandleScope::new(scope); let local = v8::Object::new(scope); - let weak = v8::Weak::new(scope, &local); + let weak = v8::Weak::new(scope, local); assert!(!weak.is_empty()); assert_eq!(weak, local); assert_eq!(weak.to_local(scope), Some(local)); @@ -7408,7 +7410,7 @@ fn finalizers() { let scope = &mut v8::HandleScope::new(scope); let local = v8::Object::new(scope); let _ = - v8::Weak::with_finalizer(scope, &local, Box::new(|_| unreachable!())); + v8::Weak::with_finalizer(scope, local, Box::new(|_| unreachable!())); } let scope = &mut v8::HandleScope::new(scope); @@ -7429,7 +7431,7 @@ fn finalizers() { let weak = Rc::new(v8::Weak::with_finalizer( scope, - &local, + local, Box::new(move |_| { let (weak, finalizer_called) = rx.try_recv().unwrap(); finalizer_called.set(true); @@ -7475,7 +7477,7 @@ fn guaranteed_finalizers() { let local = v8::Object::new(scope); let _ = v8::Weak::with_guaranteed_finalizer( scope, - &local, + local, Box::new(|| unreachable!()), ); } @@ -7498,7 +7500,7 @@ fn guaranteed_finalizers() { let weak = Rc::new(v8::Weak::with_guaranteed_finalizer( scope, - &local, + local, Box::new(move || { let (weak, finalizer_called) = rx.try_recv().unwrap(); finalizer_called.set(true); @@ -7568,10 +7570,10 @@ fn weak_from_into_raw() { let (weak1, weak2) = { let scope = &mut v8::HandleScope::new(scope); let local = v8::Object::new(scope); - let weak = v8::Weak::new(scope, &local); + let weak = v8::Weak::new(scope, local); let weak_with_finalizer = v8::Weak::with_finalizer( scope, - &local, + local, Box::new({ let finalizer_called = finalizer_called.clone(); move |_| { @@ -7601,7 +7603,7 @@ fn weak_from_into_raw() { let weak = { let scope = &mut v8::HandleScope::new(scope); let local = v8::Object::new(scope); - v8::Weak::new(scope, &local) + v8::Weak::new(scope, local) }; assert!(!weak.is_empty()); eval(scope, "gc()").unwrap(); @@ -7615,10 +7617,10 @@ fn weak_from_into_raw() { let (weak, weak_with_finalizer) = { let scope = &mut v8::HandleScope::new(scope); let local = v8::Object::new(scope); - let weak = v8::Weak::new(scope, &local); + let weak = v8::Weak::new(scope, local); let weak_with_finalizer = v8::Weak::with_finalizer( scope, - &local, + local, Box::new({ let finalizer_called = finalizer_called.clone(); move |_| { @@ -7674,7 +7676,7 @@ fn drop_weak_from_raw_in_finalizer() { let local = v8::Object::new(scope); let weak = v8::Weak::with_finalizer( scope, - &local, + local, Box::new({ let weak_ptr = weak_ptr.clone(); let finalized = finalized.clone(); @@ -7749,10 +7751,10 @@ fn finalizer_on_kept_global() { let scope = &mut v8::ContextScope::new(scope, context); let object = v8::Object::new(scope); - global = v8::Global::new(scope, &object); + global = v8::Global::new(scope, object); weak1 = v8::Weak::with_finalizer( scope, - &object, + object, Box::new({ let finalized = regular_finalized.clone(); move |_| finalized.set(true) @@ -7760,7 +7762,7 @@ fn finalizer_on_kept_global() { ); weak2 = v8::Weak::with_guaranteed_finalizer( scope, - &object, + object, Box::new({ let guaranteed_finalized = guaranteed_finalized.clone(); move || guaranteed_finalized.set(true)