diff options
Diffstat (limited to 'tests/ui/borrowck/borrowck-borrow-from-expr-block.rs')
-rw-r--r-- | tests/ui/borrowck/borrowck-borrow-from-expr-block.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-borrow-from-expr-block.rs b/tests/ui/borrowck/borrowck-borrow-from-expr-block.rs new file mode 100644 index 000000000..24efadc30 --- /dev/null +++ b/tests/ui/borrowck/borrowck-borrow-from-expr-block.rs @@ -0,0 +1,17 @@ +// run-pass + +fn borrow<F>(x: &isize, f: F) where F: FnOnce(&isize) { + f(x) +} + +fn test1(x: &Box<isize>) { + borrow(&*(*x).clone(), |p| { + let x_a = &**x as *const isize; + assert!((x_a as usize) != (p as *const isize as usize)); + assert_eq!(unsafe{*x_a}, *p); + }) +} + +pub fn main() { + test1(&Box::new(22)); +} |