Skip to content

Commit 41d1602

Browse files
authored
Merge pull request #719 from RalfJung/stacked-borrows-2
add arielby's example
2 parents 7842335 + 617195e commit 41d1602

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn main() {
2+
let x = &mut 0u32;
3+
let p = x as *mut u32;
4+
foo(x, p);
5+
}
6+
7+
fn foo(a: &mut u32, y: *mut u32) -> u32 {
8+
*a = 1;
9+
let _b = &*a;
10+
unsafe { *y = 2; } //~ ERROR: borrow stack
11+
return *a;
12+
}

0 commit comments

Comments
 (0)