diff options
| author | Michael Scholten <michael-scholten@hotmail.nl> | 2024-04-23 11:47:51 +0200 |
|---|---|---|
| committer | Michael Scholten <michael-scholten@hotmail.nl> | 2024-04-24 09:41:44 +0200 |
| commit | 3c5e88c7d19fee810ce5bdaaae8c9da8caabd6eb (patch) | |
| tree | 1719e31cb7b317a8546ce2a4d6bd9f4a52756ceb /compiler/rustc_lexer | |
| parent | c67277301c896857d0534f2bb7431680796833fb (diff) | |
| download | rust-3c5e88c7d19fee810ce5bdaaae8c9da8caabd6eb.tar.gz rust-3c5e88c7d19fee810ce5bdaaae8c9da8caabd6eb.zip | |
Improved the compiler code with clippy
Diffstat (limited to 'compiler/rustc_lexer')
| -rw-r--r-- | compiler/rustc_lexer/src/lib.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_lexer/src/unescape.rs | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_lexer/src/lib.rs b/compiler/rustc_lexer/src/lib.rs index 83fff98bad5..6f8a9792b6c 100644 --- a/compiler/rustc_lexer/src/lib.rs +++ b/compiler/rustc_lexer/src/lib.rs @@ -630,7 +630,7 @@ impl Cursor<'_> { // with a number self.bump(); let mut empty_exponent = false; - if self.first().is_digit(10) { + if self.first().is_ascii_digit() { self.eat_decimal_digits(); match self.first() { 'e' | 'E' => { @@ -661,7 +661,7 @@ impl Cursor<'_> { // If the first symbol is valid for identifier, it can be a lifetime. // Also check if it's a number for a better error reporting (so '0 will // be reported as invalid lifetime and not as unterminated char literal). - is_id_start(self.first()) || self.first().is_digit(10) + is_id_start(self.first()) || self.first().is_ascii_digit() }; if !can_be_a_lifetime { @@ -677,7 +677,7 @@ impl Cursor<'_> { // Either a lifetime or a character literal with // length greater than 1. - let starts_with_number = self.first().is_digit(10); + let starts_with_number = self.first().is_ascii_digit(); // Skip the literal contents. // First symbol can be a number (which isn't a valid identifier start), diff --git a/compiler/rustc_lexer/src/unescape.rs b/compiler/rustc_lexer/src/unescape.rs index 03d178eb266..d6ea4249247 100644 --- a/compiler/rustc_lexer/src/unescape.rs +++ b/compiler/rustc_lexer/src/unescape.rs @@ -259,7 +259,7 @@ fn scan_escape<T: From<char> + From<u8>>( } else { // This may be a high byte, but that will only happen if `T` is // `MixedUnit`, because of the `allow_high_bytes` check above. - Ok(T::from(value as u8)) + Ok(T::from(value)) }; } 'u' => return scan_unicode(chars, mode.allow_unicode_escapes()).map(T::from), @@ -300,7 +300,7 @@ fn scan_unicode(chars: &mut Chars<'_>, allow_unicode_escapes: bool) -> Result<ch return Err(EscapeError::UnicodeEscapeInByte); } - break std::char::from_u32(value).ok_or_else(|| { + break std::char::from_u32(value).ok_or({ if value > 0x10FFFF { EscapeError::OutOfRangeUnicodeEscape } else { |
