]> git.proxmox.com Git - rustc.git/blame - src/test/ui/associated-type-bounds/implied-region-constraints.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / associated-type-bounds / implied-region-constraints.rs
CommitLineData
dc9dc135
XL
1#![feature(associated_type_bounds)]
2
3trait Tr1 { type As1; }
4trait Tr2 { type As2; }
5
6struct St<'a, 'b, T: Tr1<As1: Tr2>> { // `T: 'b` is *not* implied!
7 f0: &'a T, // `T: 'a` is implied.
8 f1: &'b <T::As1 as Tr2>::As2, // `<T::As1 as Tr2>::As2: 'a` is implied.
9}
10
11fn _bad_st<'a, 'b, T>(x: St<'a, 'b, T>)
12where
13 T: Tr1,
14 T::As1: Tr2,
15{
16 // This should fail because `T: 'b` is not implied from `WF(St<'a, 'b, T>)`.
17 let _failure_proves_not_implied_outlives_region_b: &'b T = &x.f0;
923072b8 18 //~^ ERROR lifetime may not live long enough
dc9dc135
XL
19}
20
21enum En7<'a, 'b, T> // `<T::As1 as Tr2>::As2: 'a` is implied.
22where
23 T: Tr1,
24 T::As1: Tr2,
25{
26 V0(&'a T),
27 V1(&'b <T::As1 as Tr2>::As2),
28}
29
30fn _bad_en7<'a, 'b, T>(x: En7<'a, 'b, T>)
31where
32 T: Tr1,
33 T::As1: Tr2,
34{
35 match x {
36 En7::V0(x) => {
37 // Also fails for the same reason as above:
38 let _failure_proves_not_implied_outlives_region_b: &'b T = &x;
923072b8 39 //~^ ERROR lifetime may not live long enough
dc9dc135
XL
40 },
41 En7::V1(_) => {},
42 }
43}
44
45fn main() {}