rust/tests/ui/borrowck/borrowck-borrow-from-expr-block.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
339 B
Rust
Raw Normal View History

//@ run-pass
2013-10-23 03:49:18 -05:00
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));
}