]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/multiple-lifetimes/error-handling.rs
New upstream version 1.66.0+dfsg1
[rustc.git] / src / test / ui / impl-trait / multiple-lifetimes / error-handling.rs
CommitLineData
94222f64 1#![feature(type_alias_impl_trait)]
dc9dc135
XL
2
3#[derive(Clone)]
4struct CopyIfEq<T, U>(T, U);
5
6impl<T: Copy> Copy for CopyIfEq<T, T> {}
7
416331ca 8type E<'a, 'b> = impl Sized;
dc9dc135
XL
9
10fn foo<'a, 'b, 'c>(x: &'static i32, mut y: &'a i32) -> E<'b, 'c> {
74b04a01
XL
11 let v = CopyIfEq::<*mut _, *mut _>(&mut { x }, &mut y);
12
13 // This assignment requires that `x` and `y` have the same type due to the
14 // `Copy` impl. The reason why we are using a copy to create a constraint
15 // is that only borrow checking (not regionck in type checking) enforces
16 // this bound.
dc9dc135
XL
17 let u = v;
18 let _: *mut &'a i32 = u.1;
74b04a01
XL
19 unsafe {
20 let _: &'b i32 = *u.0;
21 //~^ ERROR lifetime may not live long enough
22 }
dc9dc135
XL
23 u.0
24}
25
26fn main() {}