Unclosed string literals cause unhelpful diagnostic
Open
Nobody has claimed this yet.
A-diagnostics
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
fn main() { "a"-a"; }
Current output
error: prefix `a` is unknown
--> src/main.rs:1:17
|
1 | fn main() { "a"-a"; }
| ^ unknown prefix
|
= note: prefixed identifiers and literals are reserved since Rust 2021
help: consider inserting whitespace here
|
1 | fn main() { "a"-a "; }
| +
error[E0765]: unterminated double quote string
--> src/main.rs:1:18
|
1 | fn main() { "a"-a"; }
| ^^^^
Desired output
error[E0765]: unterminated double quote string
--> src/main.rs:1:18
|
1 | fn main() { "a"-a"; }
| ^ ^^^^ here
| help: you may have meant to close this string instead: `"a""`
= note: prefixed identifiers and literals are reserved since Rust 2021
Rationale and extra context
Confusing error when dealing with long unclosed string literals and command line options.
Other cases
No response
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.
Research direction
Reproduce the case in src/main.rs with rustc and compare the current and desired diagnostics, then trace the compiler diagnostic responsible for the prefixed identifier and unterminated string messages. Done means the unclosed-string case emits the requested E0765 diagnostic, including the suggested closing string and note, without the misleading prefix error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100