Skip to content

Account for item-local, out of scope bindings, in E0425 #104700

Closed
@estebank

Description

@estebank

When encountering a binding that is not available

     let foo = 1;
    {
        let bar = 2;
    }
    println!("{foo} {bar}");

the error should mention bindings that are outside of the scope but within the same item

error[E0425]: cannot find value `bar` in this scope
 --> src/main.rs:6:22
  |
6 |     println!("{foo} {bar}");
  |                      ^^^ not found in this scope
note: the binding `bar` is available in a different scope in the same function
 --> src/main.rs:4:8
  |
4 |         let bar = 2;
  |             ^^^

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-resolveArea: Name/path resolution done by `rustc_resolve` specificallyD-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.P-lowLow priorityT-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