-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code, which won't compile because of (edited: #49733) #29641
fn main() {
let box = Box::new(1);
}
yields an unhelpful error message:
error: expected pattern, found `=`
--> src/main.rs:2:13
|
2 | let box = Box::new(1);
| ^ expected pattern
Particularly confusing if your text editor doesn't highlight box
! It would be nicer to show some help proposing to rename the variable.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Unhelpful error message with variables named `box`[/-][+]Unhelpful error message with identifiers named `box`[/+]ChayimFriedman2 commentedon Jun 7, 2022
@rustbot claim
est31 commentedon Jun 7, 2022
@rstk FTR you linked to the wrong issue, you should have linked to #29641, as it's a box pattern not a box expression in the case of your snippet.
box
as identifier #97857Rollup merge of rust-lang#97857 - ChayimFriedman2:box-identifier-help…
Rollup merge of rust-lang#97857 - ChayimFriedman2:box-identifier-help…