-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-type-systemArea: Type systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone
Description
fn main()
{
let mut x = [mut 1, 2, 4];
let v : &int = &x[2];
x[2] = 6;
assert *v == 6;
}
gives me
/Users/jruderman/Desktop/a.rs:5:3: 5:6 error: assigning to mutable vec content prohibited due to outstanding loan
/Users/jruderman/Desktop/a.rs:5 x[2] = 6;
^~~
/Users/jruderman/Desktop/a.rs:4:19: 4:22 note: loan of mutable vec content granted here
/Users/jruderman/Desktop/a.rs:4 let v : &int = &x[2];
^~~
I think the error message should emphasize that it is an immutable loan. So it's clear that if you were to change it to a mutable loan, it's okay.
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-type-systemArea: Type systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.