]>
Commit | Line | Data |
---|---|---|
74b04a01 XL |
1 | // compile-flags:-Zborrowck=mir |
2 | ||
3 | #![feature(member_constraints)] | |
94222f64 | 4 | #![feature(type_alias_impl_trait)] |
74b04a01 XL |
5 | |
6 | #[derive(Clone)] | |
7 | struct CopyIfEq<T, U>(T, U); | |
8 | ||
9 | impl<T: Copy> Copy for CopyIfEq<T, T> {} | |
10 | ||
11 | type E<'a, 'b> = impl Sized; | |
12 | ||
13 | fn foo<'a: 'b, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> { | |
14 | //~^ ERROR hidden type for `impl Trait` captures lifetime that does not appear in bounds | |
15 | let v = CopyIfEq::<*mut _, *mut _>(&mut { x }, &mut y); | |
16 | ||
17 | // This assignment requires that `x` and `y` have the same type due to the | |
18 | // `Copy` impl. The reason why we are using a copy to create a constraint | |
19 | // is that only borrow checking (not regionck in type checking) enforces | |
20 | // this bound. | |
21 | let u = v; | |
22 | let _: *mut &'a i32 = u.1; | |
23 | unsafe { | |
24 | let _: &'b i32 = *u.0; | |
25 | } | |
26 | u.0 | |
27 | } | |
28 | ||
29 | fn main() {} |