Skip to content

Commit 43a2cbd

Browse files
committed
lifetime elision: add conforming-to-fn tests.
1 parent 0452340 commit 43a2cbd

8 files changed

+341
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
struct Struct { }
12+
13+
type Alias = Struct;
14+
15+
impl Struct {
16+
// Test using an alias for `Struct`:
17+
18+
async fn alias(self: Alias, f: &u32) -> &u32 {
19+
f
20+
}
21+
22+
async fn box_Alias(self: Box<Alias>, f: &u32) -> &u32 {
23+
f
24+
}
25+
26+
async fn rc_Alias(self: Rc<Alias>, f: &u32) -> &u32 {
27+
f
28+
}
29+
30+
async fn box_box_Alias(self: Box<Box<Alias>>, f: &u32) -> &u32 {
31+
f
32+
}
33+
34+
async fn box_rc_Alias(self: Box<Rc<Alias>>, f: &u32) -> &u32 {
35+
f
36+
}
37+
}
38+
39+
fn main() { }
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
trait Trait {
12+
type AssocType;
13+
}
14+
15+
struct Struct { }
16+
17+
impl Trait for Struct {
18+
type AssocType = Self;
19+
}
20+
21+
impl Struct {
22+
async fn assoc(self: <Struct as Trait>::AssocType, f: &u32) -> &u32 {
23+
f
24+
}
25+
26+
async fn box_AssocType(self: Box<<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
27+
f
28+
}
29+
30+
async fn rc_AssocType(self: Rc<<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
31+
f
32+
}
33+
34+
async fn box_box_AssocType(self: Box<Box<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
35+
f
36+
}
37+
38+
async fn box_rc_AssocType(self: Box<Rc<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
39+
f
40+
}
41+
}
42+
43+
fn main() { }
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
struct Struct<'a> { x: &'a u32 }
12+
13+
type Alias<'a> = Struct<'a>;
14+
15+
impl<'a> Alias<'a> {
16+
async fn take_self(self, f: &u32) -> &u32 {
17+
f
18+
}
19+
20+
async fn take_Alias(self: Alias<'a>, f: &u32) -> &u32 {
21+
f
22+
}
23+
24+
async fn take_Box_Alias(self: Box<Alias<'a>>, f: &u32) -> &u32 {
25+
f
26+
}
27+
28+
async fn take_Box_Box_Alias(self: Box<Box<Alias<'a>>>, f: &u32) -> &u32 {
29+
f
30+
}
31+
32+
async fn take_Rc_Alias(self: Rc<Alias<'a>>, f: &u32) -> &u32 {
33+
f
34+
}
35+
36+
async fn take_Box_Rc_Alias(self: Box<Rc<Alias<'a>>>, f: &u32) -> &u32 {
37+
f
38+
}
39+
}
40+
41+
fn main() { }
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
trait Trait {
12+
type AssocType;
13+
}
14+
15+
struct Struct<'a> { x: &'a u32 }
16+
17+
impl<'a> Trait for Struct<'a> {
18+
type AssocType = Self;
19+
}
20+
21+
impl<'a> Struct<'a> {
22+
async fn take_self(self, f: &u32) -> &u32 {
23+
f
24+
}
25+
26+
async fn take_AssocType(self: <Struct<'a> as Trait>::AssocType, f: &u32) -> &u32 {
27+
f
28+
}
29+
30+
async fn take_Box_AssocType(self: Box<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 {
31+
f
32+
}
33+
34+
async fn take_Box_Box_AssocType(
35+
self: Box<Box<<Struct<'a> as Trait>::AssocType>>,
36+
f: &u32
37+
) -> &u32 {
38+
f
39+
}
40+
41+
async fn take_Rc_AssocType(self: Rc<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 {
42+
f
43+
}
44+
45+
async fn take_Box_Rc_AssocType(
46+
self: Box<Rc<<Struct<'a> as Trait>::AssocType>>,
47+
f: &u32
48+
) -> &u32 {
49+
f
50+
}
51+
}
52+
53+
fn main() { }
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::pin::Pin;
10+
use std::rc::Rc;
11+
12+
struct Struct<'a> {
13+
x: &'a u32
14+
}
15+
16+
impl<'a> Struct<'a> {
17+
async fn take_self(self, f: &u32) -> &u32 {
18+
f
19+
}
20+
21+
async fn take_Self(self: Self, f: &u32) -> &u32 {
22+
f
23+
}
24+
25+
async fn take_Box_Self(self: Box<Self>, f: &u32) -> &u32 {
26+
f
27+
}
28+
29+
async fn take_Box_Box_Self(self: Box<Box<Self>>, f: &u32) -> &u32 {
30+
f
31+
}
32+
33+
async fn take_Rc_Self(self: Rc<Self>, f: &u32) -> &u32 {
34+
f
35+
}
36+
37+
async fn take_Box_Rc_Self(self: Box<Rc<Self>>, f: &u32) -> &u32 {
38+
f
39+
}
40+
41+
// N/A
42+
//fn take_Pin_Self(self: Pin<Self>, f: &u32) -> &u32 {
43+
// f
44+
//}
45+
46+
// N/A
47+
//fn take_Box_Pin_Self(self: Box<Pin<Self>>, f: &u32) -> &u32 {
48+
// f
49+
//}
50+
}
51+
52+
fn main() { }
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
struct Struct<'a> { x: &'a u32 }
12+
13+
impl<'a> Struct<'a> {
14+
async fn take_self(self, f: &u32) -> &u32 {
15+
f
16+
}
17+
18+
async fn take_Struct(self: Struct<'a>, f: &u32) -> &u32 {
19+
f
20+
}
21+
22+
async fn take_Box_Struct(self: Box<Struct<'a>>, f: &u32) -> &u32 {
23+
f
24+
}
25+
26+
async fn take_Box_Box_Struct(self: Box<Box<Struct<'a>>>, f: &u32) -> &u32 {
27+
f
28+
}
29+
30+
async fn take_Rc_Struct(self: Rc<Struct<'a>>, f: &u32) -> &u32 {
31+
f
32+
}
33+
34+
async fn take_Box_Rc_Struct(self: Box<Rc<Struct<'a>>>, f: &u32) -> &u32 {
35+
f
36+
}
37+
}
38+
39+
fn main() { }
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
struct Struct { }
12+
13+
impl Struct {
14+
async fn take_self(self, f: &u32) -> &u32 {
15+
f
16+
}
17+
18+
async fn take_Self(self: Self, f: &u32) -> &u32 {
19+
f
20+
}
21+
22+
async fn take_Box_Self(self: Box<Self>, f: &u32) -> &u32 {
23+
f
24+
}
25+
26+
async fn take_Box_Box_Self(self: Box<Box<Self>>, f: &u32) -> &u32 {
27+
f
28+
}
29+
30+
async fn take_Rc_Self(self: Rc<Self>, f: &u32) -> &u32 {
31+
f
32+
}
33+
34+
async fn take_Box_Rc_Self(self: Box<Rc<Self>>, f: &u32) -> &u32 {
35+
f
36+
}
37+
}
38+
39+
fn main() { }
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// check-pass
2+
// edition:2018
3+
4+
#![feature(async_await)]
5+
6+
#![feature(arbitrary_self_types)]
7+
#![allow(non_snake_case)]
8+
9+
use std::rc::Rc;
10+
11+
struct Struct { }
12+
13+
impl Struct {
14+
async fn ref_Struct(self: Struct, f: &u32) -> &u32 {
15+
f
16+
}
17+
18+
async fn box_Struct(self: Box<Struct>, f: &u32) -> &u32 {
19+
f
20+
}
21+
22+
async fn rc_Struct(self: Rc<Struct>, f: &u32) -> &u32 {
23+
f
24+
}
25+
26+
async fn box_box_Struct(self: Box<Box<Struct>>, f: &u32) -> &u32 {
27+
f
28+
}
29+
30+
async fn box_rc_Struct(self: Box<Rc<Struct>>, f: &u32) -> &u32 {
31+
f
32+
}
33+
}
34+
35+
fn main() { }

0 commit comments

Comments
 (0)