Wrong error for string literal suffix when stuck together
Open
@notJoon is already working on this.
Since Aug 19, 2025.
A-diagnostics
A-parser
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.2k
- PR merge metrics
- PR metrics pending
Description
Code
let s = r#" \ "#r"\ ";
Current output
error: unknown character escape: ` `
--> src/main.rs:2:20
|
2 | let s = r#" \ "#r"\ ";
| ^ unknown character escape
|
= help: for more information, visit <https://doc.rust-lang.org/reference/tokens.html#literals>
help: if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal
|
2 | let s = r#" \ "#rr"\ ";
| +
error: expected one of `.`, `;`, `?`, `else`, or an operator, found `"\ "`
--> src/main.rs:2:18
|
2 | let s = r#" \ "#r"\ ";
| ^^^^ expected one of `.`, `;`, `?`, `else`, or an operator
Desired output
error: suffixes on string literals are invalid
--> src/main.rs:2:9
|
2 | let s = r#" \ "#r"\ ";
| ^^^^^^^^^ invalid suffix `r`
Rationale and extra context
It seems like #r is not considered as a suffix whereas it should
Other cases
Rust Version
1.90.0-nightly (2025-07-17 e4662966273ed58b51f9)
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.