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