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