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