You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct Bar { value: ~str }
struct TreeMap { dummy: () }
impl TreeMap {
fn find_mut<'s>(&'s mut self) -> Option<&'s mut Bar> {
fail!();
}
}
fn foo<'a>(map: &'a mut TreeMap) -> &'a mut Bar {
{
let r = map.find_mut();
if r.is_some() {
return r.unwrap();
}
} // <-- first borrow could end here
{
let s = map.find_mut();
if s.is_some() {
return s.unwrap();
}
}
fail!();
} // <-- compiler reports it ends here
fn main() {}
Compiler emits the error:
/home/vagrant/hashmap.rs:21:17: 21:20 error: cannot borrow `*map` as mutable more than once at a time
/home/vagrant/hashmap.rs:21 let s = map.find_mut();
^~~
/home/vagrant/hashmap.rs:14:17: 14:20 note: previous borrow of `*map` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `*map` until the borrow ends
/home/vagrant/hashmap.rs:14 let r = map.find_mut();
^~~
/home/vagrant/hashmap.rs:28:2: 28:2 note: previous borrow ends here
/home/vagrant/hashmap.rs:12 fn foo<'a>(map: &'a mut TreeMap) -> &'a mut Bar {
...
/home/vagrant/hashmap.rs:28 }
^
error: aborting due to previous error
Compiler reports that first borrow ends at the end of function, however, variable r is destroyed near 6th line of the function.
The text was updated successfully, but these errors were encountered:
…ro, r=Veykril
Revert "Add proc-macro dependency to rustc crates"
1. This panics since it indexes into the wrong thing, so fixesrust-lang/rust-analyzer#13340
2. This didn't fix what I thought it would either
Reverts rust-lang/rust-analyzer#13328
Code:
Compiler emits the error:
Compiler reports that first borrow ends at the end of function, however, variable
r
is destroyed near 6th line of the function.The text was updated successfully, but these errors were encountered: