From 59ceddd8879a8abf1886cc42fe8935cb03e39c97 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Thu, 5 Oct 2023 20:58:19 -0600 Subject: [PATCH] Fix new lints for Rust 1.73 --- boa_ast/src/lib.rs | 1 - boa_cli/src/main.rs | 1 - boa_engine/src/builtins/string/mod.rs | 2 +- boa_engine/src/bytecompiler/mod.rs | 2 - boa_engine/src/lib.rs | 1 - boa_engine/src/string/mod.rs | 2 +- boa_engine/src/symbol.rs | 2 +- boa_engine/src/value/conversions/mod.rs | 1 + boa_engine/src/value/operations.rs | 2 +- boa_gc/src/lib.rs | 5 +- boa_icu_provider/src/lib.rs | 1 - boa_interner/src/lib.rs | 1 - boa_macros/src/lib.rs | 1 - boa_parser/src/error/mod.rs | 57 ++++++++----------- boa_parser/src/lib.rs | 1 - .../expression/left_hand_side/optional/mod.rs | 2 +- boa_profiler/src/lib.rs | 1 - boa_runtime/src/lib.rs | 1 - boa_tester/src/exec/mod.rs | 2 +- boa_tester/src/main.rs | 1 - boa_wasm/src/lib.rs | 1 - 21 files changed, 34 insertions(+), 54 deletions(-) diff --git a/boa_ast/src/lib.rs b/boa_ast/src/lib.rs index 2a8430d4b98..921eea03922 100644 --- a/boa_ast/src/lib.rs +++ b/boa_ast/src/lib.rs @@ -70,7 +70,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( clippy::module_name_repetitions, diff --git a/boa_cli/src/main.rs b/boa_cli/src/main.rs index 961d1200bf3..31f9a72b54d 100644 --- a/boa_cli/src/main.rs +++ b/boa_cli/src/main.rs @@ -57,7 +57,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] mod debug; diff --git a/boa_engine/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs index 8147b2c5a0d..6f476b2b125 100644 --- a/boa_engine/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -730,7 +730,7 @@ impl String { Ok(js_string!(result).into()) } // 5. If n is 0, return the empty String. - IntegerOrInfinity::Integer(n) if n == 0 => Ok(js_string!().into()), + IntegerOrInfinity::Integer(0) => Ok(js_string!().into()), // 4. If n < 0 or n is +∞, throw a RangeError exception. _ => Err(JsNativeError::range() .with_message( diff --git a/boa_engine/src/bytecompiler/mod.rs b/boa_engine/src/bytecompiler/mod.rs index a8b734a8ada..4ed65fcb329 100644 --- a/boa_engine/src/bytecompiler/mod.rs +++ b/boa_engine/src/bytecompiler/mod.rs @@ -1098,7 +1098,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { for variable in decl.0.as_ref() { match variable.binding() { Binding::Identifier(ident) => { - let ident = ident; if let Some(expr) = variable.init() { self.compile_expr(expr, true); self.emit_binding(BindingOpcode::InitVar, *ident); @@ -1126,7 +1125,6 @@ impl<'ctx, 'host> ByteCompiler<'ctx, 'host> { for variable in decls.as_ref() { match variable.binding() { Binding::Identifier(ident) => { - let ident = ident; if let Some(expr) = variable.init() { self.compile_expr(expr, true); } else { diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index 809b87f6b28..3775454c8b9 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -103,7 +103,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( // Currently throws a false positive regarding dependencies that are only used in benchmarks. diff --git a/boa_engine/src/string/mod.rs b/boa_engine/src/string/mod.rs index b35abe1da8f..7483a0897e9 100644 --- a/boa_engine/src/string/mod.rs +++ b/boa_engine/src/string/mod.rs @@ -843,7 +843,7 @@ impl PartialEq for str { impl PartialOrd for JsString { fn partial_cmp(&self, other: &Self) -> Option { - self[..].partial_cmp(other) + Some(self.cmp(other)) } } diff --git a/boa_engine/src/symbol.rs b/boa_engine/src/symbol.rs index 375eada8bf6..cd087d31ed0 100644 --- a/boa_engine/src/symbol.rs +++ b/boa_engine/src/symbol.rs @@ -340,7 +340,7 @@ impl PartialEq for JsSymbol { impl PartialOrd for JsSymbol { #[inline] fn partial_cmp(&self, other: &Self) -> Option { - self.hash().partial_cmp(&other.hash()) + Some(self.cmp(other)) } } diff --git a/boa_engine/src/value/conversions/mod.rs b/boa_engine/src/value/conversions/mod.rs index 255ca3d1a38..0b2d02035dc 100644 --- a/boa_engine/src/value/conversions/mod.rs +++ b/boa_engine/src/value/conversions/mod.rs @@ -165,6 +165,7 @@ impl From for JsValue { impl From<()> for JsValue { #[inline] + #[allow(clippy::pedantic)] // didn't want to increase our MSRV for just a lint. fn from(_: ()) -> Self { let _timer = Profiler::global().start_event("From<()>", "value"); diff --git a/boa_engine/src/value/operations.rs b/boa_engine/src/value/operations.rs index cc35839e99e..44fe42b37a1 100644 --- a/boa_engine/src/value/operations.rs +++ b/boa_engine/src/value/operations.rs @@ -477,7 +477,7 @@ impl JsValue { ), Self::String(ref str) => Self::new(-str.to_number()), Self::Rational(num) => Self::new(-num), - Self::Integer(num) if num == 0 => Self::new(-f64::from(0)), + Self::Integer(0) => Self::new(-f64::from(0)), Self::Integer(num) => Self::new(-num), Self::Boolean(true) => Self::new(1), Self::Boolean(false) | Self::Null => Self::new(0), diff --git a/boa_gc/src/lib.rs b/boa_gc/src/lib.rs index acbe0a0e024..698f6001bd8 100644 --- a/boa_gc/src/lib.rs +++ b/boa_gc/src/lib.rs @@ -62,7 +62,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( clippy::module_name_repetitions, @@ -329,7 +328,7 @@ impl Collector { } } - fn trace_non_roots(gc: &mut BoaGc) { + fn trace_non_roots(gc: &BoaGc) { // Count all the handles located in GC heap. // Then, we can find whether there is a reference from other places, and they are the roots. let mut strong = &gc.strong_start; @@ -522,7 +521,7 @@ impl Collector { } // Clean up the heap when BoaGc is dropped - fn dump(gc: &mut BoaGc) { + fn dump(gc: &BoaGc) { // Weak maps have to be dropped first, since the process dereferences GcBoxes. // This can be done without initializing a dropguard since no GcBox's are being dropped. let weak_map_head = &gc.weak_map_start; diff --git a/boa_icu_provider/src/lib.rs b/boa_icu_provider/src/lib.rs index 0b1b4aae44e..0a9aa072dde 100644 --- a/boa_icu_provider/src/lib.rs +++ b/boa_icu_provider/src/lib.rs @@ -70,7 +70,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow(elided_lifetimes_in_paths)] #![cfg_attr(not(feature = "bin"), no_std)] diff --git a/boa_interner/src/lib.rs b/boa_interner/src/lib.rs index 4475823f255..9ac053b4214 100644 --- a/boa_interner/src/lib.rs +++ b/boa_interner/src/lib.rs @@ -67,7 +67,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( clippy::redundant_pub_crate, diff --git a/boa_macros/src/lib.rs b/boa_macros/src/lib.rs index 0851ec37d4d..c56fb5f1e0b 100644 --- a/boa_macros/src/lib.rs +++ b/boa_macros/src/lib.rs @@ -57,7 +57,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] use proc_macro::TokenStream; diff --git a/boa_parser/src/error/mod.rs b/boa_parser/src/error/mod.rs index 9f9077877f6..7805be2c668 100644 --- a/boa_parser/src/error/mod.rs +++ b/boa_parser/src/error/mod.rs @@ -183,38 +183,31 @@ impl fmt::Display for Error { found, span, context, - } => write!( - f, - "expected {}, got '{found}' in {context} at line {}, col {}", - if expected.len() == 1 { - format!( - "token '{}'", - expected.first().expect("already checked that length is 1") - ) - } else { - format!( - "one of {}", - expected - .iter() - .enumerate() - .map(|(i, t)| { - format!( - "{}'{t}'", - if i == 0 { - "" - } else if i == expected.len() - 1 { - " or " - } else { - ", " - }, - ) - }) - .collect::() - ) - }, - span.start().line_number(), - span.start().column_number() - ), + } => { + write!(f, "expected ")?; + match &**expected { + [single] => write!(f, "token '{single}'")?, + expected => { + write!(f, "one of ")?; + for (i, token) in expected.iter().enumerate() { + let prefix = if i == 0 { + "" + } else if i == expected.len() - 1 { + " or " + } else { + ", " + }; + write!(f, "{prefix}'{token}'")?; + } + } + } + write!( + f, + ", got '{found}' in {context} at line {}, col {}", + span.start().line_number(), + span.start().column_number() + ) + } Self::Unexpected { found, span, diff --git a/boa_parser/src/lib.rs b/boa_parser/src/lib.rs index ff2e35e9783..fa7433173f3 100644 --- a/boa_parser/src/lib.rs +++ b/boa_parser/src/lib.rs @@ -67,7 +67,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( clippy::module_name_repetitions, diff --git a/boa_parser/src/parser/expression/left_hand_side/optional/mod.rs b/boa_parser/src/parser/expression/left_hand_side/optional/mod.rs index 725b40494f9..42248fd3a37 100644 --- a/boa_parser/src/parser/expression/left_hand_side/optional/mod.rs +++ b/boa_parser/src/parser/expression/left_hand_side/optional/mod.rs @@ -62,7 +62,7 @@ where fn parse(self, cursor: &mut Cursor, interner: &mut Interner) -> ParseResult { fn parse_const_access( token: &Token, - interner: &mut Interner, + interner: &Interner, ) -> ParseResult { let item = match token.kind() { TokenKind::IdentifierName((name, _)) => { diff --git a/boa_profiler/src/lib.rs b/boa_profiler/src/lib.rs index 801465953b2..2723c958c04 100644 --- a/boa_profiler/src/lib.rs +++ b/boa_profiler/src/lib.rs @@ -64,7 +64,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![cfg_attr(not(feature = "profiler"), no_std)] diff --git a/boa_runtime/src/lib.rs b/boa_runtime/src/lib.rs index ab6dc889cc6..08860c0111d 100644 --- a/boa_runtime/src/lib.rs +++ b/boa_runtime/src/lib.rs @@ -96,7 +96,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( clippy::module_name_repetitions, diff --git a/boa_tester/src/exec/mod.rs b/boa_tester/src/exec/mod.rs index 8d0201d39c0..356e3d831fc 100644 --- a/boa_tester/src/exec/mod.rs +++ b/boa_tester/src/exec/mod.rs @@ -634,7 +634,7 @@ fn register_print_fn(context: &mut Context<'_>, async_result: AsyncResult) { let mut result = async_result.inner.borrow_mut(); match *result { - UninitResult::Uninit | UninitResult::Ok(_) => { + UninitResult::Uninit | UninitResult::Ok(()) => { if message == "Test262:AsyncTestComplete" { *result = UninitResult::Ok(()); } else { diff --git a/boa_tester/src/main.rs b/boa_tester/src/main.rs index 66ad305f114..2ca77a94b9f 100644 --- a/boa_tester/src/main.rs +++ b/boa_tester/src/main.rs @@ -60,7 +60,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] #![allow( clippy::too_many_lines, diff --git a/boa_wasm/src/lib.rs b/boa_wasm/src/lib.rs index f296fcebdc0..45027194b3e 100644 --- a/boa_wasm/src/lib.rs +++ b/boa_wasm/src/lib.rs @@ -57,7 +57,6 @@ clippy::complexity, clippy::perf, clippy::pedantic, - clippy::nursery, )] use boa_engine::{Context, Source};