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