Skip to content

Commit

Permalink
Fix clippy 1.62.0 lints (#2154)
Browse files Browse the repository at this point in the history
This Pull Request changes the following:

- Fix clippy 1.62.0 lints
  • Loading branch information
raskad committed Jun 30, 2022
1 parent f7aef10 commit 6b4ebf9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions boa_engine/src/builtins/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
// $$
Expand Down
6 changes: 5 additions & 1 deletion boa_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
)]

Expand Down
2 changes: 1 addition & 1 deletion boa_engine/src/syntax/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ impl<R> Lexer<R> {
_ 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)
}
_ => {
Expand Down
6 changes: 3 additions & 3 deletions boa_engine/src/syntax/lexer/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<R> Tokenizer<R> 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(),
Expand Down Expand Up @@ -277,11 +277,11 @@ impl<R> Tokenizer<R> 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.
Expand Down

0 comments on commit 6b4ebf9

Please sign in to comment.