From e96933bc163fd81a276cbc169b17f76724a5ac33 Mon Sep 17 00:00:00 2001 From: Mathias Lafeldt Date: Sun, 21 Aug 2022 19:31:14 +0200 Subject: [PATCH] chore: use Rust 1.63.0 (#15464) --- .cargo/config.toml | 2 ++ cli/main.rs | 4 +--- cli/tools/test.rs | 2 +- core/async_cancel.rs | 2 +- core/inspector.rs | 1 + core/modules.rs | 2 +- core/ops_builtin_v8.rs | 1 + ext/ffi/lib.rs | 11 ++++++++--- ext/net/io.rs | 1 + ext/net/ops.rs | 1 + rust-toolchain.toml | 2 +- serde_v8/magic/buffer.rs | 6 +++--- serde_v8/magic/v8slice.rs | 1 + serde_v8/serializable.rs | 2 +- test_util/src/lib.rs | 3 ++- 15 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index cac99a377e..cc76825227 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -23,4 +23,6 @@ rustflags = [ "clippy::missing_safety_doc", "-D", "clippy::undocumented_unsafe_blocks", + "-A", + "clippy::derive-partial-eq-without-eq", ] diff --git a/cli/main.rs b/cli/main.rs index 17f3fcffa7..8e53d1f0cf 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1070,9 +1070,7 @@ pub fn main() { logger::init(flags.log_level); - let exit_code = get_subcommand(flags).await; - - exit_code + get_subcommand(flags).await }; let exit_code = unwrap_or_exit(run_local(exit_code)); diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 6d24a7e4ce..da44eba7c3 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -752,7 +752,7 @@ fn extract_files_from_regex_blocks( return None; } - match attributes.get(0) { + match attributes.first() { Some(&"js") => MediaType::JavaScript, Some(&"javascript") => MediaType::JavaScript, Some(&"mjs") => MediaType::Mjs, diff --git a/core/async_cancel.rs b/core/async_cancel.rs index 55ab8f4d14..11b07e1891 100644 --- a/core/async_cancel.rs +++ b/core/async_cancel.rs @@ -219,7 +219,7 @@ mod internal { // Do a cancellation check _before_ polling the inner future. If it has // already been canceled the inner future will not be polled. let node = match &*registration { - Registration::WillRegister { head_node } => &*head_node, + Registration::WillRegister { head_node } => head_node, Registration::Registered { node } => node, }; if node.is_canceled() { diff --git a/core/inspector.rs b/core/inspector.rs index bec22d2573..6a254b76c6 100644 --- a/core/inspector.rs +++ b/core/inspector.rs @@ -438,6 +438,7 @@ struct InspectorWakerInner { isolate_handle: v8::IsolateHandle, } +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Send for InspectorWakerInner {} struct InspectorWaker(Mutex); diff --git a/core/modules.rs b/core/modules.rs index c4fa53b516..545ad54d84 100644 --- a/core/modules.rs +++ b/core/modules.rs @@ -1346,7 +1346,7 @@ import "/a.js"; Err(..) => return Err(MockError::ResolveErr.into()), }; - if mock_source_code(&output_specifier.to_string()).is_some() { + if mock_source_code(output_specifier.as_ref()).is_some() { Ok(output_specifier) } else { Err(MockError::ResolveErr.into()) diff --git a/core/ops_builtin_v8.rs b/core/ops_builtin_v8.rs index b828f908d6..fe6a38bb4c 100644 --- a/core/ops_builtin_v8.rs +++ b/core/ops_builtin_v8.rs @@ -673,6 +673,7 @@ fn op_set_wasm_streaming_callback( Ok(()) } +#[allow(clippy::let_and_return)] #[op(v8)] fn op_abort_wasm_streaming( scope: &mut v8::HandleScope, diff --git a/ext/ffi/lib.rs b/ext/ffi/lib.rs index 6d0bda6494..1d400069e8 100644 --- a/ext/ffi/lib.rs +++ b/ext/ffi/lib.rs @@ -97,7 +97,9 @@ struct Symbol { } #[allow(clippy::non_send_fields_in_send_ty)] +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Send for Symbol {} +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Sync for Symbol {} #[derive(Clone)] @@ -123,7 +125,9 @@ impl PtrSymbol { } #[allow(clippy::non_send_fields_in_send_ty)] +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Send for PtrSymbol {} +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Sync for PtrSymbol {} struct DynamicLibraryResource { @@ -363,7 +367,7 @@ impl NativeValue { } NativeType::ISize => { let value = self.isize_value; - if value > MAX_SAFE_INTEGER || value < MIN_SAFE_INTEGER { + if !(MIN_SAFE_INTEGER..=MAX_SAFE_INTEGER).contains(&value) { json!(U32x2::from(self.isize_value as u64)) } else { Value::from(value) @@ -458,7 +462,7 @@ impl NativeValue { NativeType::ISize => { let value = self.isize_value; let local_value: v8::Local = - if value > MAX_SAFE_INTEGER || value < MIN_SAFE_INTEGER { + if !(MIN_SAFE_INTEGER..=MAX_SAFE_INTEGER).contains(&value) { v8::BigInt::new_from_i64(scope, self.isize_value as i64).into() } else { v8::Number::new(scope, value as f64).into() @@ -489,6 +493,7 @@ impl NativeValue { } } +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Send for NativeValue {} #[derive(Serialize, Debug, Clone, Copy)] @@ -1979,7 +1984,7 @@ fn op_ffi_get_static<'scope>( // SAFETY: ptr is user provided let result = unsafe { ptr::read_unaligned(data_ptr as *const isize) }; let integer: v8::Local = - if result > MAX_SAFE_INTEGER || result < MIN_SAFE_INTEGER { + if !(MIN_SAFE_INTEGER..=MAX_SAFE_INTEGER).contains(&result) { v8::BigInt::new_from_i64(scope, result as i64).into() } else { v8::Number::new(scope, result as f64).into() diff --git a/ext/net/io.rs b/ext/net/io.rs index 02caf7473b..c9587c8518 100644 --- a/ext/net/io.rs +++ b/ext/net/io.rs @@ -136,6 +136,7 @@ impl TcpStreamResource { .map_socket(Box::new(move |socket| Ok(socket.set_keepalive(keepalive)?))) } + #[allow(clippy::type_complexity)] fn map_socket( self: Rc, map: Box Result<(), AnyError>>, diff --git a/ext/net/ops.rs b/ext/net/ops.rs index 87bfc32722..a05c21da87 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -1047,6 +1047,7 @@ mod tests { check_sockopt(String::from("127.0.0.1:4246"), set_keepalive, test_fn).await; } + #[allow(clippy::type_complexity)] async fn check_sockopt( addr: String, set_sockopt_fn: Box, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9e2065b1c8..4a6c266200 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.62.1" +channel = "1.63.0" components = ["rustfmt", "clippy"] diff --git a/serde_v8/magic/buffer.rs b/serde_v8/magic/buffer.rs index da87c8b867..db50e38967 100644 --- a/serde_v8/magic/buffer.rs +++ b/serde_v8/magic/buffer.rs @@ -58,7 +58,7 @@ impl Clone for ZeroCopyBuf { impl AsRef<[u8]> for ZeroCopyBuf { fn as_ref(&self) -> &[u8] { - &*self + self } } @@ -72,8 +72,8 @@ impl Deref for ZeroCopyBuf { type Target = [u8]; fn deref(&self) -> &[u8] { match self { - Self::FromV8(buf) => &*buf, - Self::Temp(vec) => &*vec, + Self::FromV8(buf) => buf, + Self::Temp(vec) => vec, Self::ToV8(_) => panic!("Don't Deref a ZeroCopyBuf sent to v8"), } } diff --git a/serde_v8/magic/v8slice.rs b/serde_v8/magic/v8slice.rs index 94e21b0e09..4772abd426 100644 --- a/serde_v8/magic/v8slice.rs +++ b/serde_v8/magic/v8slice.rs @@ -25,6 +25,7 @@ pub struct V8Slice { pub(crate) range: Range, } +// SAFETY: unsafe trait must have unsafe implementation unsafe impl Send for V8Slice {} impl V8Slice { diff --git a/serde_v8/serializable.rs b/serde_v8/serializable.rs index abde544c76..7820d02ecd 100644 --- a/serde_v8/serializable.rs +++ b/serde_v8/serializable.rs @@ -39,7 +39,7 @@ impl SerializablePkg { &self, scope: &mut v8::HandleScope<'a>, ) -> Result, crate::Error> { - match &*self { + match self { Self::Primitive(x) => crate::to_v8(scope, x), Self::Serializable(x) => x.to_v8(scope), } diff --git a/test_util/src/lib.rs b/test_util/src/lib.rs index 79c74aef87..d15538e545 100644 --- a/test_util/src/lib.rs +++ b/test_util/src/lib.rs @@ -1052,6 +1052,7 @@ impl hyper::server::accept::Accept for HyperAcceptor<'_> { } #[allow(clippy::non_send_fields_in_send_ty)] +// SAFETY: unsafe trait must have unsafe implementation unsafe impl std::marker::Send for HyperAcceptor<'_> {} async fn wrap_redirect_server() { @@ -1897,7 +1898,7 @@ impl<'a> CheckOutputIntegrationTest<'a> { // deno test's output capturing flushes with a zero-width space in order to // synchronize the output pipes. Occassionally this zero width space // might end up in the output so strip it from the output comparison here. - if args.get(0) == Some(&"test") { + if args.first() == Some(&"test") { actual = actual.replace('\u{200B}', ""); }