]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-borrow-from-expr-block.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-borrow-from-expr-block.rs
1 // run-pass
2
3 fn borrow<F>(x: &isize, f: F) where F: FnOnce(&isize) {
4     f(x)
5 }
6
7 fn test1(x: &Box<isize>) {
8     borrow(&*(*x).clone(), |p| {
9         let x_a = &**x as *const isize;
10         assert!((x_a as usize) != (p as *const isize as usize));
11         assert_eq!(unsafe{*x_a}, *p);
12     })
13 }
14
15 pub fn main() {
16     test1(&Box::new(22));
17 }