Skip to content

Commit fdf1cc4

Browse files
committed
Add tests for self: (&)AssocType
1 parent f916aa9 commit fdf1cc4

File tree

3 files changed

+124
-0
lines changed

3 files changed

+124
-0
lines changed

src/test/ui/self/elision/assoc.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// check-pass
2+
3+
#![feature(arbitrary_self_types)]
4+
#![allow(non_snake_case)]
5+
6+
use std::rc::Rc;
7+
8+
trait Trait {
9+
type AssocType;
10+
}
11+
12+
struct Struct { }
13+
14+
impl Trait for Struct {
15+
type AssocType = Self;
16+
}
17+
18+
impl Struct {
19+
fn assoc(self: <Struct as Trait>::AssocType, f: &u32) -> &u32 {
20+
f
21+
}
22+
23+
fn box_AssocType(self: Box<<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
24+
f
25+
}
26+
27+
fn rc_AssocType(self: Rc<<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
28+
f
29+
}
30+
31+
fn box_box_AssocType(self: Box<Box<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
32+
f
33+
}
34+
35+
fn box_rc_AssocType(self: Box<Rc<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
36+
f
37+
}
38+
}
39+
40+
fn main() { }

src/test/ui/self/elision/lt-assoc.rs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// check-pass
2+
3+
#![feature(arbitrary_self_types)]
4+
#![allow(non_snake_case)]
5+
6+
use std::rc::Rc;
7+
8+
trait Trait {
9+
type AssocType;
10+
}
11+
12+
struct Struct<'a> { x: &'a u32 }
13+
14+
impl<'a> Trait for Struct<'a> {
15+
type AssocType = Self;
16+
}
17+
18+
impl<'a> Struct<'a> {
19+
fn take_self(self, f: &u32) -> &u32 {
20+
f
21+
}
22+
23+
fn take_AssocType(self: <Struct<'a> as Trait>::AssocType, f: &u32) -> &u32 {
24+
f
25+
}
26+
27+
fn take_Box_AssocType(self: Box<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 {
28+
f
29+
}
30+
31+
fn take_Box_Box_AssocType(self: Box<Box<<Struct<'a> as Trait>::AssocType>>, f: &u32) -> &u32 {
32+
f
33+
}
34+
35+
fn take_Rc_AssocType(self: Rc<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 {
36+
f
37+
}
38+
39+
fn take_Box_Rc_AssocType(self: Box<Rc<<Struct<'a> as Trait>::AssocType>>, f: &u32) -> &u32 {
40+
f
41+
}
42+
}
43+
44+
fn main() { }

src/test/ui/self/elision/ref-assoc.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// check-pass
2+
3+
#![feature(arbitrary_self_types)]
4+
#![allow(non_snake_case)]
5+
6+
use std::pin::Pin;
7+
8+
trait Trait {
9+
type AssocType;
10+
}
11+
12+
struct Struct { }
13+
14+
impl Trait for Struct {
15+
type AssocType = Self;
16+
}
17+
18+
impl Struct {
19+
fn ref_AssocType(self: &<Struct as Trait>::AssocType, f: &u32) -> &u32 {
20+
f
21+
}
22+
23+
fn box_ref_AssocType(self: Box<&<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
24+
f
25+
}
26+
27+
fn pin_ref_AssocType(self: Pin<&<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
28+
f
29+
}
30+
31+
fn box_box_ref_AssocType(self: Box<Box<&<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
32+
f
33+
}
34+
35+
fn box_pin_ref_AssocType(self: Box<Pin<&<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
36+
f
37+
}
38+
}
39+
40+
fn main() { }

0 commit comments

Comments
 (0)