fix: incorrect error message for string literal suffixes#145602
fix: incorrect error message for string literal suffixes#145602notJoon wants to merge 7 commits intorust-lang:mainfrom
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. |
|
@notJoon any updates on this? thanks |
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
|
@Dylan-DPC sorry for the delay, I'll take a look this asap. thanks for the remind |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
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_litto handle raw string literals with suffixes by:LitKind::from_token_litto validate and get the appropriate errorTo prevent cascading errors, consume the next token if it's another string literal after an error is reported.