]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/self_implication.rs
Rollup merge of #104965 - zacklukem:p-option-as_ref-docs, r=scottmcm
[rust.git] / tests / ui / type-alias-impl-trait / self_implication.rs
1 // check-pass
2
3 #![feature(type_alias_impl_trait)]
4 fn foo() {
5     struct Foo<'a> {
6         x: &'a mut u8,
7     }
8     impl<'a> Foo<'a> {
9         fn foo(&self) -> impl Sized {}
10     }
11     // use site
12     let mut x = 5;
13     let y = Foo { x: &mut x };
14     let z = y.foo();
15     let _a = &x; // invalidate the `&'a mut`in `y`
16     let _b = z; // this should *not* check that `'a` in the type `Foo<'a>::foo::opaque` is live
17 }
18
19 fn bar() {
20     struct Foo<'a> {
21         x: &'a mut u8,
22     }
23
24     // desugared
25     type FooX<'a> = impl Sized;
26     impl<'a> Foo<'a> {
27         fn foo(&self) -> FooX<'a> {}
28     }
29
30     // use site
31     let mut x = 5;
32     let y = Foo { x: &mut x };
33     let z = y.foo();
34     let _a = &x; // invalidate the `&'a mut`in `y`
35     let _b = z; // this should *not* check that `'a` in the type `Foo<'a>::foo::opaque` is live
36 }
37
38 fn main() {}