]> git.lizzy.rs Git - rust.git/blob - src/test/ui/self/elision/ref-self.rs
Rollup merge of #63055 - Mark-Simulacrum:save-analysis-clean-2, r=Xanewok
[rust.git] / src / test / ui / self / elision / ref-self.rs
1 #![feature(arbitrary_self_types)]
2 #![allow(non_snake_case)]
3
4 use std::marker::PhantomData;
5 use std::ops::Deref;
6 use std::pin::Pin;
7
8 struct Struct { }
9
10 struct Wrap<T, P>(T, PhantomData<P>);
11
12 impl<T, P> Deref for Wrap<T, P> {
13     type Target = T;
14     fn deref(&self) -> &T { &self.0 }
15 }
16
17 impl Struct {
18     // Test using `&self` sugar:
19
20     fn ref_self(&self, f: &u32) -> &u32 {
21         f //~ ERROR lifetime mismatch
22     }
23
24     // Test using `&Self` explicitly:
25
26     fn ref_Self(self: &Self, f: &u32) -> &u32 {
27         f //~ ERROR lifetime mismatch
28     }
29
30     fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
31         f //~ ERROR lifetime mismatch
32     }
33
34     fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
35         f //~ ERROR lifetime mismatch
36     }
37
38     fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
39         f //~ ERROR lifetime mismatch
40     }
41
42     fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
43         f //~ ERROR lifetime mismatch
44     }
45
46     fn wrap_ref_Self_Self(self: Wrap<&Self, Self>, f: &u8) -> &u8 {
47         f //~ ERROR lifetime mismatch
48     }
49 }
50
51 fn main() { }