Browse Source

Fix clippy 1.62.0 lints (#2154)

This Pull Request changes the following:

- Fix clippy 1.62.0 lints
pull/2153/head
raskad 2 years ago
parent
commit
6b4ebf9e3e
  1. 4
      boa_engine/src/builtins/string/mod.rs
  2. 6
      boa_engine/src/lib.rs
  3. 2
      boa_engine/src/syntax/lexer/mod.rs
  4. 6
      boa_engine/src/syntax/lexer/number.rs

4
boa_engine/src/builtins/string/mod.rs

@ -2140,10 +2140,10 @@ pub(crate) fn get_substitution(
while let Some(first) = chars.next() { while let Some(first) = chars.next() {
if first == '$' { if first == '$' {
let second = chars.next(); 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 // 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 = 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) { match (second, third) {
// $$ // $$

6
boa_engine/src/lib.rs

@ -52,7 +52,6 @@
nonstandard_style, nonstandard_style,
)] )]
#![allow( #![allow(
clippy::use_self, // TODO: deny once false positives are fixed
clippy::module_name_repetitions, clippy::module_name_repetitions,
clippy::cast_possible_truncation, clippy::cast_possible_truncation,
clippy::cast_sign_loss, clippy::cast_sign_loss,
@ -68,6 +67,11 @@
clippy::missing_errors_doc, clippy::missing_errors_doc,
clippy::as_conversions, clippy::as_conversions,
clippy::let_unit_value, 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 rustdoc::missing_doc_code_examples
)] )]

2
boa_engine/src/syntax/lexer/mod.rs

@ -280,7 +280,7 @@ impl<R> Lexer<R> {
_ if Identifier::is_identifier_start(c as u32) => { _ if Identifier::is_identifier_start(c as u32) => {
Identifier::new(c).lex(&mut self.cursor, start, interner) 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) NumberLiteral::new(next_ch as u8).lex(&mut self.cursor, start, interner)
} }
_ => { _ => {

6
boa_engine/src/syntax/lexer/number.rs

@ -209,7 +209,7 @@ impl<R> Tokenizer<R> for NumberLiteral {
kind = NumericKind::Integer(16); kind = NumericKind::Integer(16);
// Checks if the next char after '0x' is a digit of that base. if not return an error. // 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( return Err(Error::syntax(
"expected hexadecimal digit after number base prefix", "expected hexadecimal digit after number base prefix",
cursor.pos(), cursor.pos(),
@ -277,11 +277,11 @@ impl<R> Tokenizer<R> for NumberLiteral {
take_integer(&mut buf, cursor, NumericKind::Integer(8), false)?; 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 // LegacyOctalIntegerLiteral
kind = NumericKind::Integer(8); 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 // 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 // so therefore this must be a number with an unneeded leading 0. This is
// forbidden in strict mode. // forbidden in strict mode.

Loading…
Cancel
Save