-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goal
Milestone
Description
e.g. in E0596:
fn main() {
let x = 1;
let y = &mut x; //[ast]~ ERROR [E0596]
//[mir]~^ ERROR [E0596]
}
AST borrowck knows that x
is an "immutable local variable", but MIR semi-inaccurately calls it an immutable item:
error[E0596]: cannot borrow immutable local variable `x` as mutable (Ast)
--> /home/ariel/Rust/rust-master/src/test/compile-fail/E0596.rs:16:18
|
15 | let x = 1;
| - consider changing this to `mut x`
16 | let y = &mut x; //[ast]~ ERROR [E0596]
| ^ cannot borrow mutably
error[E0596]: cannot borrow immutable item `x` as mutable (Mir)
--> /home/ariel/Rust/rust-master/src/test/compile-fail/E0596.rs:16:13
|
16 | let y = &mut x; //[ast]~ ERROR [E0596]
| ^^^^^^ cannot borrow as mutable
error: aborting due to 2 previous errors
The AST code for doing that is actually in mem_categorization
, and should be ported to MIR borrowck:
rust/src/librustc/middle/mem_categorization.rs
Line 1450 in 02b4d3d
pub fn descriptive_string(&self, tcx: TyCtxt) -> String { |
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.NLL-diagnosticsWorking towards the "diagnostic parity" goalWorking towards the "diagnostic parity" goal