suggest hex escapes for C-style escapes#156376
Conversation
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
|
r? @mu001999 rustbot has assigned @mu001999. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
I don't think that the "(perhaps transcribing from another language)" part is useful to the diagnostic. It should be clear from context that Rust simply does this differently. |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
|
@rustbot ready |
suggest hex escapes for C-style escapes Fixes rust-lang#148884.
|
@bors r- |
|
This pull request was unapproved. This PR was contained in a rollup (#156432), which was unapproved. |
|
@rustbot ready |
| let (name, hex) = match escaped_char { | ||
| "a" => ("an audible bell", String::from("07")), | ||
| "b" => ("a backspace", String::from("08")), | ||
| "f" => ("a form feed", String::from("0C")), | ||
| "v" => ("a vertical tab", String::from("0B")), | ||
| "e" => ("an ANSI escape sequence", String::from("1B")), | ||
| ec if u8::from_str_radix(ec, 8).is_ok() => { | ||
| diag.help(r"if you meant to write an ASCII control code, use a `\xNN` hex escape"); | ||
| return; | ||
| } | ||
| _ => return, | ||
| }; |
There was a problem hiding this comment.
| let (name, hex) = match escaped_char { | |
| "a" => ("an audible bell", String::from("07")), | |
| "b" => ("a backspace", String::from("08")), | |
| "f" => ("a form feed", String::from("0C")), | |
| "v" => ("a vertical tab", String::from("0B")), | |
| "e" => ("an ANSI escape sequence", String::from("1B")), | |
| ec if u8::from_str_radix(ec, 8).is_ok() => { | |
| diag.help(r"if you meant to write an ASCII control code, use a `\xNN` hex escape"); | |
| return; | |
| } | |
| _ => return, | |
| }; | |
| if u8::from_str_radix(escaped_char, 8).is_ok() { | |
| diag.help(r"if you meant to write an ASCII control code, use a `\xNN` hex escape"); | |
| return; | |
| } | |
| let (name, hex) = match escaped_char { | |
| "a" => ("an audible bell", "07"), | |
| "b" => ("a backspace", "08"), | |
| "f" => ("a form feed", "0C"), | |
| "v" => ("a vertical tab", "0B"), | |
| "e" => ("an ANSI escape sequence", "1B"), | |
| _ => return, | |
| }; |
View all comments
Fixes #148884.