]> git.proxmox.com Git - rustc.git/blame - src/test/ui/impl-trait/multiple-lifetimes/error-handling-2.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / src / test / ui / impl-trait / multiple-lifetimes / error-handling-2.rs
CommitLineData
94222f64 1#![feature(type_alias_impl_trait)]
74b04a01
XL
2
3#[derive(Clone)]
4struct CopyIfEq<T, U>(T, U);
5
6impl<T: Copy> Copy for CopyIfEq<T, T> {}
7
8type E<'a, 'b> = impl Sized;
9
10fn foo<'a: 'b, '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.
17 let u = v;
18 let _: *mut &'a i32 = u.1;
19 unsafe {
20 let _: &'b i32 = *u.0;
21 }
22 u.0
064997fb 23 //~^ ERROR hidden type for `E<'b, 'c>` captures lifetime that does not appear in bounds
74b04a01
XL
24}
25
26fn main() {}