-
Notifications
You must be signed in to change notification settings - Fork 13.7k
fix: incorrect error message for string literal suffixes #145602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rustbot has assigned @petrochenkov. Use |
This is incorrect, the string literal suffix is a semantic error, not a parsing error, and this code #[cfg(false)]
fn check() {
let _ = r#"raw"#suffix;
} should compile successfully. @rustbot author |
Reminder, once the PR becomes ready for a review, use |
☔ The latest upstream changes (presumably #144689) made this pull request unmergeable. Please resolve the merge conflicts. |
Description
Fixes #144161
When a raw string literal has an invalid suffix (like
r#"test"#suffix
), the compiler was not reporting the appropriate error message "suffixes on string literals are invalid". This was particularly problematic when the suffix was immediately followed by another token, as inr#" \\ "#r"\\ "
.Changes
Modified
parse_expr_lit
to handle raw string literals with suffixes by:LitKind::from_token_lit
to validate and get the appropriate errorTo prevent cascading errors, consume the next token if it's another string literal after an error is reported.