X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_lexer%2Fsrc%2Funescape.rs;h=87c44638a8de1918883375cd0d6357dfebd8a16b;hb=d7bc758638772dbc5718eb33347998cfce0bee5e;hp=e405013dcabf83047cb34a88c635e6d4d7ec8a28;hpb=ebf579932dd3c89c64368e23501310611b0e0ccf;p=rust.git diff --git a/compiler/rustc_lexer/src/unescape.rs b/compiler/rustc_lexer/src/unescape.rs index e405013dcab..87c44638a8d 100644 --- a/compiler/rustc_lexer/src/unescape.rs +++ b/compiler/rustc_lexer/src/unescape.rs @@ -204,14 +204,13 @@ fn scan_escape(chars: &mut Chars<'_>, is_byte: bool) -> Result { - let digit = + let digit: u32 = c.to_digit(16).ok_or(EscapeError::InvalidCharInUnicodeEscape)?; n_digits += 1; if n_digits > 6 { // Stop updating value since we're sure that it's incorrect already. continue; } - let digit = digit as u32; value = value * 16 + digit; } };