-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
I'm not sure if anyone has raised this, but maybe this error reporting could be improved to also say "consider adding
+ use<>
rather than just complaining about an immutable borrow?error[E0502]: cannot borrow `data` as mutable because it is also borrowed as immutable --> src/main.rs:6:5 | 5 | let mut i = indices(&data); | ----- immutable borrow occurs here 6 | data.push(4); | ^^^^^^^^^^^^ mutable borrow occurs here 7 | i.next(); | - immutable borrow later used hereInstead,
error[E0502]: cannot borrow `data` as mutable because it is also borrowed as immutable --> src/main.rs:6:5 | 5 | let mut i = indices(&data); | ----- immutable borrow occurs here 6 | data.push(4); | ^^^^^^^^^^^^ mutable borrow occurs here 7 | i.next(); | - immutable borrow later used here 10 | fn indices<T>( 11 | slice: &[T], 12 | ) -> impl Iterator<Item = usize> + use<> { | ----- `impl Trait` must mention all type parameters in scope in `use<...>`
bsodmike
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.