]> git.lizzy.rs Git - rust.git/blob - tests/ui/regions/regions-lifetime-nonfree-late-bound.rs
internally change regions to be covariant
[rust.git] / tests / ui / regions / regions-lifetime-nonfree-late-bound.rs
1 // run-pass
2 // This is a regression test for the ICE from issue #10846.
3 //
4 // The original issue causing the ICE: the LUB-computations during
5 // type inference were encountering late-bound lifetimes, and
6 // asserting that such lifetimes should have already been substituted
7 // with a concrete lifetime.
8 //
9 // However, those encounters were occurring within the lexical scope
10 // of the binding for the late-bound lifetime; that is, the late-bound
11 // lifetimes were perfectly valid.  The core problem was that the type
12 // folding code was over-zealously passing back all lifetimes when
13 // doing region-folding, when really all clients of the region-folding
14 // case only want to see FREE lifetime variables, not bound ones.
15
16 // pretty-expanded FIXME #23616
17
18 pub fn main() {
19     fn explicit() {
20         fn test<F>(_x: Option<Box<F>>) where F: FnMut(Box<dyn for<'a> FnMut(&'a isize)>) {}
21         test(Some(Box::new(|_f: Box<dyn for<'a> FnMut(&'a isize)>| {})));
22     }
23
24     // The code below is shorthand for the code above (and more likely
25     // to represent what one encounters in practice).
26     fn implicit() {
27         fn test<F>(_x: Option<Box<F>>) where F: FnMut(Box<dyn        FnMut(&   isize)>) {}
28         test(Some(Box::new(|_f: Box<dyn        FnMut(&   isize)>| {})));
29     }
30
31     explicit();
32     implicit();
33 }