diff options
| author | Laurențiu Nicola <lnicola@dend.ro> | 2024-06-20 08:03:36 +0300 |
|---|---|---|
| committer | Laurențiu Nicola <lnicola@dend.ro> | 2024-06-20 08:03:36 +0300 |
| commit | 9d2bb7f40ff91c36b590e743a6e9a92153159d1c (patch) | |
| tree | 0343d8f8c519d3e76f27f77fbae414eb88ef2738 /compiler/rustc_parse_format | |
| parent | 35d0bcd89fa7454093abcf2c7a8624782c269375 (diff) | |
| parent | 3d5d7a24f76006b391d8a53d903ae64c1b4a52d2 (diff) | |
| download | rust-9d2bb7f40ff91c36b590e743a6e9a92153159d1c.tar.gz rust-9d2bb7f40ff91c36b590e743a6e9a92153159d1c.zip | |
Merge from rust-lang/rust
Diffstat (limited to 'compiler/rustc_parse_format')
| -rw-r--r-- | compiler/rustc_parse_format/src/lib.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index faf6ca78467..7e22644977d 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -4,14 +4,16 @@ //! Parsing does not happen at runtime: structures of `std::fmt::rt` are //! generated instead. +// tidy-alphabetical-start +// We want to be able to build this crate with a stable compiler, +// so no `#![feature]` attributes should be added. +#![deny(unstable_features)] #![doc( html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/", html_playground_url = "https://play.rust-lang.org/", test(attr(deny(warnings))) )] -// We want to be able to build this crate with a stable compiler, -// so no `#![feature]` attributes should be added. -#![deny(unstable_features)] +// tidy-alphabetical-end use rustc_lexer::unescape; pub use Alignment::*; @@ -286,13 +288,11 @@ impl<'a> Iterator for Parser<'a> { lbrace_byte_pos.to(InnerOffset(rbrace_byte_pos.0 + width)), ); } - } else { - if let Some(&(_, maybe)) = self.cur.peek() { - match maybe { - '?' => self.suggest_format_debug(), - '<' | '^' | '>' => self.suggest_format_align(maybe), - _ => self.suggest_positional_arg_instead_of_captured_arg(arg), - } + } else if let Some(&(_, maybe)) = self.cur.peek() { + match maybe { + '?' => self.suggest_format_debug(), + '<' | '^' | '>' => self.suggest_format_align(maybe), + _ => self.suggest_positional_arg_instead_of_captured_arg(arg), } } Some(NextArgument(Box::new(arg))) @@ -1028,7 +1028,7 @@ fn find_width_map_from_snippet( if next_c == '{' { // consume up to 6 hexanumeric chars let digits_len = - s.clone().take(6).take_while(|(_, c)| c.is_digit(16)).count(); + s.clone().take(6).take_while(|(_, c)| c.is_ascii_hexdigit()).count(); let len_utf8 = s .as_str() @@ -1047,14 +1047,14 @@ fn find_width_map_from_snippet( width += required_skips + 2; s.nth(digits_len); - } else if next_c.is_digit(16) { + } else if next_c.is_ascii_hexdigit() { width += 1; // We suggest adding `{` and `}` when appropriate, accept it here as if // it were correct let mut i = 0; // consume up to 6 hexanumeric chars while let (Some((_, c)), _) = (s.next(), i < 6) { - if c.is_digit(16) { + if c.is_ascii_hexdigit() { width += 1; } else { break; |
