]> git.proxmox.com Git - rustc.git/blame - src/test/ui/nll/closure-requirements/propagate-from-trait-match.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / nll / closure-requirements / propagate-from-trait-match.rs
CommitLineData
ff7c6d11
XL
1// Test that regions which appear only in the closure's generics (in
2// this case, `'a`) are properly mapped to the creator's generics. In
3// this case, the closure constrains its type parameter `T` to outlive
4// the same `'a` for which it implements `Trait`, which can only be the `'a`
5// from the function definition.
6
923072b8 7// compile-flags:-Zverbose
ff7c6d11
XL
8
9#![feature(rustc_attrs)]
10#![allow(dead_code)]
11
12trait Trait<'a> {}
13
14fn establish_relationships<T, F>(value: T, closure: F)
15where
16 F: FnOnce(T),
17{
18 closure(value)
19}
20
21fn require<'a, T>(t: T)
22where
23 T: Trait<'a> + 'a,
24{
25}
26
27#[rustc_regions]
28fn supply<'a, T>(value: T)
29where
30 T: Trait<'a>,
31{
32 establish_relationships(value, |value| {
33 //~^ ERROR the parameter type `T` may not live long enough
34
35 // This function call requires that
36 //
37 // (a) T: Trait<'a>
38 //
39 // and
40 //
41 // (b) T: 'a
42 //
43 // The latter does not hold.
44
45 require(value);
ff7c6d11
XL
46 });
47}
48
49fn main() {}