Skip to content

Wrong error for string literal suffix when stuck together #144161

@GuillaumeGomez

Description

@GuillaumeGomez

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions