forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kill conflicting borrows of places with projections.
Resolves rust-lang#62007. Due to a bug, the previous version of this check did not actually kill any conflicting borrows unless the borrowed place had no projections. Specifically, `entry_set` will always be empty when `statement_effect` is called. It does not contain the set of borrows which are live at this point in the program.
- Loading branch information
1 parent
f693d33
commit f045008
Showing
2 changed files
with
46 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/test/run-pass/borrowck/borrowck-borrow-of-projection-kills-other-borrows-issue-62007.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// run-pass | ||
#![allow(dead_code)] | ||
|
||
struct List<T> { | ||
value: T, | ||
next: Option<Box<List<T>>>, | ||
} | ||
|
||
fn to_refs<T>(mut list: (&mut List<T>,)) -> Vec<&mut T> { | ||
let mut result = vec![]; | ||
loop { | ||
result.push(&mut (list.0).value); | ||
if let Some(n) = (list.0).next.as_mut() { | ||
list.0 = n; | ||
} else { | ||
return result; | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |