Skip to content

Unhelpful error message with identifiers named box #97810

Closed
@rstk

Description

@rstk

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

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTD-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.T-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