diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-08 15:06:26 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-08 15:06:26 +0200 |
| commit | 43a2cbdfd33b02be90ab1616e1b706142fa5d498 (patch) | |
| tree | 2845a91ed0e45ca9bb7655e49cc4797ac8b89d69 /src | |
| parent | 04523404bcae5904fe29a54122040a7101f5c652 (diff) | |
| download | rust-43a2cbdfd33b02be90ab1616e1b706142fa5d498.tar.gz rust-43a2cbdfd33b02be90ab1616e1b706142fa5d498.zip | |
lifetime elision: add conforming-to-fn tests.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/self/elision/alias-async.rs | 39 | ||||
| -rw-r--r-- | src/test/ui/self/elision/assoc-async.rs | 43 | ||||
| -rw-r--r-- | src/test/ui/self/elision/lt-alias-async.rs | 41 | ||||
| -rw-r--r-- | src/test/ui/self/elision/lt-assoc-async.rs | 53 | ||||
| -rw-r--r-- | src/test/ui/self/elision/lt-self-async.rs | 52 | ||||
| -rw-r--r-- | src/test/ui/self/elision/lt-struct-async.rs | 39 | ||||
| -rw-r--r-- | src/test/ui/self/elision/self-async.rs | 39 | ||||
| -rw-r--r-- | src/test/ui/self/elision/struct-async.rs | 35 |
8 files changed, 341 insertions, 0 deletions
diff --git a/src/test/ui/self/elision/alias-async.rs b/src/test/ui/self/elision/alias-async.rs new file mode 100644 index 00000000000..3d5b24a8946 --- /dev/null +++ b/src/test/ui/self/elision/alias-async.rs @@ -0,0 +1,39 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct { } + +type Alias = Struct; + +impl Struct { + // Test using an alias for `Struct`: + + async fn alias(self: Alias, f: &u32) -> &u32 { + f + } + + async fn box_Alias(self: Box<Alias>, f: &u32) -> &u32 { + f + } + + async fn rc_Alias(self: Rc<Alias>, f: &u32) -> &u32 { + f + } + + async fn box_box_Alias(self: Box<Box<Alias>>, f: &u32) -> &u32 { + f + } + + async fn box_rc_Alias(self: Box<Rc<Alias>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/assoc-async.rs b/src/test/ui/self/elision/assoc-async.rs new file mode 100644 index 00000000000..0f33f288772 --- /dev/null +++ b/src/test/ui/self/elision/assoc-async.rs @@ -0,0 +1,43 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![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 { + async fn assoc(self: <Struct as Trait>::AssocType, f: &u32) -> &u32 { + f + } + + async fn box_AssocType(self: Box<<Struct as Trait>::AssocType>, f: &u32) -> &u32 { + f + } + + async fn rc_AssocType(self: Rc<<Struct as Trait>::AssocType>, f: &u32) -> &u32 { + f + } + + async fn box_box_AssocType(self: Box<Box<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 { + f + } + + async fn box_rc_AssocType(self: Box<Rc<<Struct as Trait>::AssocType>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-alias-async.rs b/src/test/ui/self/elision/lt-alias-async.rs new file mode 100644 index 00000000000..5a8989f078e --- /dev/null +++ b/src/test/ui/self/elision/lt-alias-async.rs @@ -0,0 +1,41 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct<'a> { x: &'a u32 } + +type Alias<'a> = Struct<'a>; + +impl<'a> Alias<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Alias(self: Alias<'a>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Alias(self: Box<Alias<'a>>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Alias(self: Box<Box<Alias<'a>>>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Alias(self: Rc<Alias<'a>>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Alias(self: Box<Rc<Alias<'a>>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-assoc-async.rs b/src/test/ui/self/elision/lt-assoc-async.rs new file mode 100644 index 00000000000..98c9aa3b6c2 --- /dev/null +++ b/src/test/ui/self/elision/lt-assoc-async.rs @@ -0,0 +1,53 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![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> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_AssocType(self: <Struct<'a> as Trait>::AssocType, f: &u32) -> &u32 { + f + } + + async fn take_Box_AssocType(self: Box<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_AssocType( + self: Box<Box<<Struct<'a> as Trait>::AssocType>>, + f: &u32 + ) -> &u32 { + f + } + + async fn take_Rc_AssocType(self: Rc<<Struct<'a> as Trait>::AssocType>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_AssocType( + self: Box<Rc<<Struct<'a> as Trait>::AssocType>>, + f: &u32 + ) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-self-async.rs b/src/test/ui/self/elision/lt-self-async.rs new file mode 100644 index 00000000000..0202db8a635 --- /dev/null +++ b/src/test/ui/self/elision/lt-self-async.rs @@ -0,0 +1,52 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::pin::Pin; +use std::rc::Rc; + +struct Struct<'a> { + x: &'a u32 +} + +impl<'a> Struct<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Self(self: Self, f: &u32) -> &u32 { + f + } + + async fn take_Box_Self(self: Box<Self>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Self(self: Box<Box<Self>>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Self(self: Rc<Self>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Self(self: Box<Rc<Self>>, f: &u32) -> &u32 { + f + } + + // N/A + //fn take_Pin_Self(self: Pin<Self>, f: &u32) -> &u32 { + // f + //} + + // N/A + //fn take_Box_Pin_Self(self: Box<Pin<Self>>, f: &u32) -> &u32 { + // f + //} +} + +fn main() { } diff --git a/src/test/ui/self/elision/lt-struct-async.rs b/src/test/ui/self/elision/lt-struct-async.rs new file mode 100644 index 00000000000..c0fc63d4232 --- /dev/null +++ b/src/test/ui/self/elision/lt-struct-async.rs @@ -0,0 +1,39 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct<'a> { x: &'a u32 } + +impl<'a> Struct<'a> { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Struct(self: Struct<'a>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Struct(self: Box<Struct<'a>>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Struct(self: Box<Box<Struct<'a>>>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Struct(self: Rc<Struct<'a>>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Struct(self: Box<Rc<Struct<'a>>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/self-async.rs b/src/test/ui/self/elision/self-async.rs new file mode 100644 index 00000000000..d1dc050be0d --- /dev/null +++ b/src/test/ui/self/elision/self-async.rs @@ -0,0 +1,39 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct { } + +impl Struct { + async fn take_self(self, f: &u32) -> &u32 { + f + } + + async fn take_Self(self: Self, f: &u32) -> &u32 { + f + } + + async fn take_Box_Self(self: Box<Self>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Box_Self(self: Box<Box<Self>>, f: &u32) -> &u32 { + f + } + + async fn take_Rc_Self(self: Rc<Self>, f: &u32) -> &u32 { + f + } + + async fn take_Box_Rc_Self(self: Box<Rc<Self>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } diff --git a/src/test/ui/self/elision/struct-async.rs b/src/test/ui/self/elision/struct-async.rs new file mode 100644 index 00000000000..f7c8591ebd3 --- /dev/null +++ b/src/test/ui/self/elision/struct-async.rs @@ -0,0 +1,35 @@ +// check-pass +// edition:2018 + +#![feature(async_await)] + +#![feature(arbitrary_self_types)] +#![allow(non_snake_case)] + +use std::rc::Rc; + +struct Struct { } + +impl Struct { + async fn ref_Struct(self: Struct, f: &u32) -> &u32 { + f + } + + async fn box_Struct(self: Box<Struct>, f: &u32) -> &u32 { + f + } + + async fn rc_Struct(self: Rc<Struct>, f: &u32) -> &u32 { + f + } + + async fn box_box_Struct(self: Box<Box<Struct>>, f: &u32) -> &u32 { + f + } + + async fn box_rc_Struct(self: Box<Rc<Struct>>, f: &u32) -> &u32 { + f + } +} + +fn main() { } |
