]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-98589-closures-relate-named-regions.rs
Rollup merge of #103146 - joboet:cleanup_pthread_condvar, r=Mark-Simulacrum
[rust.git] / src / test / ui / nll / issue-98589-closures-relate-named-regions.rs
1 // Regression test for #98589.
2 // Previously, named lifetime `'a` that appears in the closure was unrelated to `'a`
3 // that appears in the parent function iff `'a` is early-bound.
4 // This made the following tests pass borrowck.
5
6 // check-fail
7
8 // The bound `'a: 'a` ensures that `'a` is early-bound.
9 fn test_early_early<'a: 'a, 'b: 'b>() {
10     || { None::<&'a &'b ()>; };
11     //~^ ERROR lifetime may not live long enough
12 }
13
14 fn test_early_late<'a: 'a, 'b>() {
15     || { None::<&'a &'b ()>; };
16     //~^ ERROR lifetime may not live long enough
17 }
18
19 // No early-bound lifetime; included for completeness.
20 fn test_late_late<'a, 'b>() {
21     || { None::<&'a &'b ()>; };
22     //~^ ERROR lifetime may not live long enough
23 }
24
25 fn test_early_type<'a: 'a, T>() {
26     || { None::<&'a T>; };
27     //~^ ERROR the parameter type `T` may not live long enough
28 }
29
30 // No early-bound lifetime; included for completeness.
31 fn test_late_type<'a, T>() {
32     || { None::<&'a T>; };
33     //~^ ERROR the parameter type `T` may not live long enough
34 }
35
36 fn main() {}