Closed
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<...>`