]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs
Rollup merge of #103418 - Aaron1011:macro-semicolon-future-incompat, r=davidtwco
[rust.git] / tests / ui / rfc-2093-infer-outlives / regions-struct-not-wf.rs
1 // Various examples of structs whose fields are not well-formed.
2
3 #![allow(dead_code)]
4
5 trait Trait<'a, T> {
6     type Out;
7 }
8 trait Trait1<'a, 'b, T> {
9     type Out;
10 }
11
12 impl<'a, T> Trait<'a, T> for usize {
13     type Out = &'a T; //~ ERROR `T` may not live long enough
14 }
15
16 struct RefOk<'a, T:'a> {
17     field: &'a T
18 }
19
20 impl<'a, T> Trait<'a, T> for u32 {
21     type Out = RefOk<'a, T>; //~ ERROR `T` may not live long enough
22 }
23
24 impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 {
25     type Out = &'a &'b T; //~ ERROR reference has a longer lifetime than the data
26 }
27
28 fn main() { }