From 6b4ebf9e3e5d61358aa502d52a230db9bc51b4cf Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:28:19 +0000 Subject: [PATCH] Fix clippy 1.62.0 lints (#2154) This Pull Request changes the following: - Fix clippy 1.62.0 lints --- boa_engine/src/builtins/string/mod.rs | 4 ++-- boa_engine/src/lib.rs | 6 +++++- boa_engine/src/syntax/lexer/mod.rs | 2 +- boa_engine/src/syntax/lexer/number.rs | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/boa_engine/src/builtins/string/mod.rs b/boa_engine/src/builtins/string/mod.rs index ec5cefb313..c5d58acf32 100644 --- a/boa_engine/src/builtins/string/mod.rs +++ b/boa_engine/src/builtins/string/mod.rs @@ -2140,10 +2140,10 @@ pub(crate) fn get_substitution( while let Some(first) = chars.next() { if first == '$' { let second = chars.next(); - let second_is_digit = second.map_or(false, |ch| ch.is_digit(10)); + let second_is_digit = second.as_ref().map_or(false, char::is_ascii_digit); // we use peek so that it is still in the iterator if not used let third = if second_is_digit { chars.peek() } else { None }; - let third_is_digit = third.map_or(false, |ch| ch.is_digit(10)); + let third_is_digit = third.map_or(false, char::is_ascii_digit); match (second, third) { // $$ diff --git a/boa_engine/src/lib.rs b/boa_engine/src/lib.rs index 626db69561..9e6e3ea26c 100644 --- a/boa_engine/src/lib.rs +++ b/boa_engine/src/lib.rs @@ -52,7 +52,6 @@ nonstandard_style, )] #![allow( - clippy::use_self, // TODO: deny once false positives are fixed clippy::module_name_repetitions, clippy::cast_possible_truncation, clippy::cast_sign_loss, @@ -68,6 +67,11 @@ clippy::missing_errors_doc, clippy::as_conversions, clippy::let_unit_value, + // Ignore because `write!(string, ...)` instead of `string.push_str(&format!(...))` can fail. + // We only use it in `ToInternedString` where performance is not an issue. + clippy::format_push_string, + // TODO deny once false positive are fixed (https://github.com/rust-lang/rust-clippy/issues/9076). + clippy::trait_duplication_in_bounds, rustdoc::missing_doc_code_examples )] diff --git a/boa_engine/src/syntax/lexer/mod.rs b/boa_engine/src/syntax/lexer/mod.rs index 87f7a12903..f122239b42 100644 --- a/boa_engine/src/syntax/lexer/mod.rs +++ b/boa_engine/src/syntax/lexer/mod.rs @@ -280,7 +280,7 @@ impl Lexer { _ if Identifier::is_identifier_start(c as u32) => { Identifier::new(c).lex(&mut self.cursor, start, interner) } - _ if c.is_digit(10) => { + _ if c.is_ascii_digit() => { NumberLiteral::new(next_ch as u8).lex(&mut self.cursor, start, interner) } _ => { diff --git a/boa_engine/src/syntax/lexer/number.rs b/boa_engine/src/syntax/lexer/number.rs index ef2a08ced5..0ad3b4e28c 100644 --- a/boa_engine/src/syntax/lexer/number.rs +++ b/boa_engine/src/syntax/lexer/number.rs @@ -209,7 +209,7 @@ impl Tokenizer for NumberLiteral { kind = NumericKind::Integer(16); // Checks if the next char after '0x' is a digit of that base. if not return an error. - if !cursor.next_is_ascii_pred(&|ch| ch.is_digit(16))? { + if !cursor.next_is_ascii_pred(&|ch| ch.is_ascii_hexdigit())? { return Err(Error::syntax( "expected hexadecimal digit after number base prefix", cursor.pos(), @@ -277,11 +277,11 @@ impl Tokenizer for NumberLiteral { take_integer(&mut buf, cursor, NumericKind::Integer(8), false)?; - if !cursor.next_is_ascii_pred(&|c| c.is_digit(10) || c == '_')? { + if !cursor.next_is_ascii_pred(&|c| c.is_ascii_digit() || c == '_')? { // LegacyOctalIntegerLiteral kind = NumericKind::Integer(8); } - } else if ch.is_digit(10) { + } else if ch.is_ascii_digit() { // Indicates a numerical digit comes after then 0 but it isn't an octal digit // so therefore this must be a number with an unneeded leading 0. This is // forbidden in strict mode.