Skip to content

Commit

Permalink
Add tests for self: (&)AssocType
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Jul 26, 2019
1 parent d79d13f commit 7369c17
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/test/ui/self/elision/assoc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// check-pass

#![feature(arbitrary_self_types)]
#![allow(non_snake_case)]

use std::rc::Rc;

trait Trait {
type AssocType;
}

struct Struct { }

impl Trait for Struct {
type AssocType = Self;
}

impl Struct {
fn assoc(self: <Struct as Trait>::AssocType, f: &u32) -> &u32 {
f
}

fn box_AssocType(self: Box<<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
f
}

fn rc_AssocType(self: Rc<<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
f
}

fn box_box_AssocType(self: Box<Box<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
f
}

fn box_rc_AssocType(self: Box<Rc<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
f
}
}

fn main() { }
44 changes: 44 additions & 0 deletions src/test/ui/self/elision/lt-assoc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// check-pass

#![feature(arbitrary_self_types)]
#![allow(non_snake_case)]

use std::rc::Rc;

trait Trait {
type AssocType;
}

struct Struct<'a> { x: &'a u32 }

impl<'a> Trait for Struct<'a> {
type AssocType = Self;
}

impl<'a> Struct<'a> {
fn take_self(self, f: &u32) -> &u32 {
f
}

fn take_AssocType(self: <Struct<'a> as Trait>::AssocType, f: &u32) -> &u32 {
f
}

fn take_Box_AssocType(self: Box<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 {
f
}

fn take_Box_Box_AssocType(self: Box<Box<<Struct<'a> as Trait>::AssocType>>, f: &u32) -> &u32 {
f
}

fn take_Rc_AssocType(self: Rc<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 {
f
}

fn take_Box_Rc_AssocType(self: Box<Rc<<Struct<'a> as Trait>::AssocType>>, f: &u32) -> &u32 {
f
}
}

fn main() { }
40 changes: 40 additions & 0 deletions src/test/ui/self/elision/ref-assoc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// check-pass

#![feature(arbitrary_self_types)]
#![allow(non_snake_case)]

use std::pin::Pin;

trait Trait {
type AssocType;
}

struct Struct { }

impl Trait for Struct {
type AssocType = Self;
}

impl Struct {
fn ref_AssocType(self: &<Struct as Trait>::AssocType, f: &u32) -> &u32 {
f
}

fn box_ref_AssocType(self: Box<&<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
f
}

fn pin_ref_AssocType(self: Pin<&<Struct as Trait>::AssocType>, f: &u32) -> &u32 {
f
}

fn box_box_ref_AssocType(self: Box<Box<&<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
f
}

fn box_pin_ref_AssocType(self: Box<Pin<&<Struct as Trait>::AssocType>>, f: &u32) -> &u32 {
f
}
}

fn main() { }

0 comments on commit 7369c17

Please sign in to comment.