]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/regions-infer-borrow-scope-within-loop.rs
Rollup merge of #87922 - Manishearth:c-enum-target-spec, r=nagisa,eddyb
[rust.git] / src / test / ui / span / regions-infer-borrow-scope-within-loop.rs
1 fn borrow<T>(x: &T) -> &T {x}
2
3 fn foo<C, M>(mut cond: C, mut make_box: M) where
4     C: FnMut() -> bool,
5     M: FnMut() -> Box<isize>,
6 {
7     let mut y: &isize;
8     loop {
9         let x = make_box();
10
11         // Here we complain because the resulting region
12         // of this borrow is the fn body as a whole.
13         y = borrow(&*x);
14         //~^ ERROR `*x` does not live long enough
15
16         assert_eq!(*x, *y);
17         if cond() { break; }
18     }
19     assert!(*y != 0);
20 }
21
22 fn main() {}