Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- let mut x: i32 = 17;
- let y: i32 = 21;
- let mut u: Vec<&/* '0 */ i32> = vec![];
- let mut v: Vec<&/* '1 */ i32> = vec![];
- /* { // NLL */
- let p: &/* '3 */ i32 = &/* '2 */x;
- let q: &/* '5 */ i32 = &/* '4 */y;
- let mut r: &/* '6 */ mut Vec<&/* '7 */ i32>;
- r = &/* '8 */ mut u;
- r.push(p);
- r = &/* '9 */ mut v;
- r.push(q);
- /* } // NLL */
- x += 1; // <-- Error! can't mutate `x` while borrowed by `u` through `p`
- // If `'0 == '1 == '7`, could the analysis (wrongly) conclude
- // that the borrowing by `v` is also problematic?
- take(v);
- }
- fn take<T>(p: T) { /* ... */ }
Add Comment
Please, Sign In to add comment