Closed
Description
The following code was working with -Zpolonius
up until rustc 1.33.0-nightly (c0bbc3927 2019-01-03)
. Since that nightly, the borrow checker fails.
Was this an intentional change? The two borrows are disjoint, so I think it should have been fine.
struct St {
x:u64,
v:Vec<u64>,
}
fn main() {
let mut s = St { x:0, v:Vec::new() };
s.v.extend((0..1).map(|a| a + s.x));
}
error[E0502]: cannot borrow `s.v` as mutable because it is also borrowed as immutable
--> src/main.rs:8:5
|
8 | s.v.extend((0..1).map(|a| a + s.x));
| ^^^^------^^^^^^^^^^^^---^^^^^-^^^^
| | | | |
| | | | first borrow occurs due to use of `s` in closure
| | | immutable borrow occurs here
| | immutable borrow later used by call
| mutable borrow occurs here
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
No labels