-
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 lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-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.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Description
Minimal example:
fn do_something<T>(collection: &mut Vec<T>) {
let a = &collection;
collection.swap(1, 2);
}
Error message (ran in playground):
rustc 1.17.0 (56124baa9 2017-04-24)
error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable
--> <anon>:3:5
|
2 | let a = &collection;
| ---------- immutable borrow occurs here
3 | collection.swap(1, 2);
| ^^^^^^^^^^ mutable borrow occurs here
4 | }
| - immutable borrow ends here
error[E0502]: cannot borrow `*collection` as mutable because `collection` is also borrowed as immutable
--> <anon>:3:5
|
2 | let a = &collection;
| ---------- immutable borrow occurs here
3 | collection.swap(1, 2);
| ^^^^^^^^^^ mutable borrow occurs here
4 | }
| - immutable borrow ends here
error: aborting due to 2 previous errors
Compilation failed.
Tested on nightly as well (rustc 1.19.0-nightly (0ed1ec9f9 2017-05-18)
)
crumblingstatue and aquelemiguel
Metadata
Metadata
Assignees
Labels
A-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.E-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.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics