mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
add a bevy of new test cases
This commit is contained in:
parent
2f64404ba3
commit
3096568904
45
src/test/ui/self/elision/README.md
Normal file
45
src/test/ui/self/elision/README.md
Normal file
@ -0,0 +1,45 @@
|
||||
Test cases intended to to document behavior and tryto exhaustively
|
||||
explore the combinations.
|
||||
|
||||
## Confidence
|
||||
|
||||
These tests are not yet considered 100% normative, in that some
|
||||
aspects of the current behavior are not desirable. This is expressed
|
||||
in the "confidence" field in the following table. Values:
|
||||
|
||||
| Confidence | Interpretation |
|
||||
| --- | --- |
|
||||
| 100% | this will remain recommended behavior |
|
||||
| 75% | unclear whether we will continue to accept this |
|
||||
| 50% | this will likely be deprecated but remain valid |
|
||||
| 25% | this could change in the future |
|
||||
| 0% | this is definitely bogus and will likely change in the future in *some* way |
|
||||
|
||||
## Tests
|
||||
|
||||
| Test file | `Self` type | Pattern | Current elision behavior | Confidence |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `self.rs` | `Struct` | `Self` | ignore `self` parameter | 100% |
|
||||
| `struct.rs` | `Struct` | `Struct` | ignore `self` parameter | 100% |
|
||||
| `alias.rs` | `Struct` | `Alias` | ignore `self` parameter | 100% |
|
||||
| `ref-self.rs` | `Struct` | `&Self` | take lifetime from `&Self` | 100% |
|
||||
| `ref-mut-self.rs` | `Struct` | `&mut Self` | take lifetime from `&Self` | 100% |
|
||||
| `ref-struct.rs` | `Struct` | `&Struct` | take lifetime from `&Self` | 50% |
|
||||
| `ref-mut-struct.rs` | `Struct` | `&Struct` | take lifetime from `&Self` | 50% |
|
||||
| `ref-alias.rs` | `Struct` | `&Alias` | ignore `Alias` | 0% |
|
||||
| `ref-mut-alias.rs` | `Struct` | `&Alias` | ignore `Alias` | 0% |
|
||||
| `lt-self.rs` | `Struct<'a>` | `Self` | ignore `Self` (and hence `'a`) | 25% |
|
||||
| `lt-struct.rs` | `Struct<'a>` | `Self` | ignore `Self` (and hence `'a`) | 0% |
|
||||
| `lt-alias.rs` | `Alias<'a>` | `Self` | ignore `Self` (and hence `'a`) | 0% |
|
||||
| `lt-ref-self.rs` | `Struct<'a>` | `&Self` | take lifetime from `&Self` | 75% |
|
||||
|
||||
In each case, we test the following patterns:
|
||||
|
||||
- `self: XXX`
|
||||
- `self: Box<XXX>`
|
||||
- `self: Pin<XXX>`
|
||||
- `self: Box<Box<XXX>>`
|
||||
- `self: Box<Pin<XXX>>`
|
||||
|
||||
In the non-reference cases, `Pin` causes errors so we substitute `Rc`.
|
||||
|
32
src/test/ui/self/elision/alias.rs
Normal file
32
src/test/ui/self/elision/alias.rs
Normal file
@ -0,0 +1,32 @@
|
||||
#![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`:
|
||||
|
||||
fn alias(self: Alias, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_Alias(self: Box<Alias>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn rc_Alias(self: Rc<Alias>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_box_Alias(self: Box<Box<Alias>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_rc_Alias(self: Box<Rc<Alias>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
}
|
7
src/test/ui/self/elision/alias.stderr
Normal file
7
src/test/ui/self/elision/alias.stderr
Normal file
@ -0,0 +1,7 @@
|
||||
error[E0601]: `main` function not found in crate `alias`
|
||||
|
|
||||
= note: consider adding a `main` function to `$DIR/alias.rs`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0601`.
|
38
src/test/ui/self/elision/lt-alias.rs
Normal file
38
src/test/ui/self/elision/lt-alias.rs
Normal file
@ -0,0 +1,38 @@
|
||||
// run-pass
|
||||
|
||||
#![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> {
|
||||
fn take_self(self, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Alias(self: Alias<'a>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Alias(self: Box<Alias<'a>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Box_Alias(self: Box<Box<Alias<'a>>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Rc_Alias(self: Rc<Alias<'a>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Rc_Alias(self: Box<Rc<Alias<'a>>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
38
src/test/ui/self/elision/lt-ref-self.rs
Normal file
38
src/test/ui/self/elision/lt-ref-self.rs
Normal file
@ -0,0 +1,38 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct<'a> { data: &'a u32 }
|
||||
|
||||
impl<'a> Struct<'a> {
|
||||
// Test using `&self` sugar:
|
||||
|
||||
fn ref_self(&self, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
// Test using `&Self` explicitly:
|
||||
|
||||
fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
62
src/test/ui/self/elision/lt-ref-self.stderr
Normal file
62
src/test/ui/self/elision/lt-ref-self.stderr
Normal file
@ -0,0 +1,62 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/lt-ref-self.rs:12:9
|
||||
|
|
||||
LL | fn ref_self(&self, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/lt-ref-self.rs:18:9
|
||||
|
|
||||
LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/lt-ref-self.rs:22:9
|
||||
|
|
||||
LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/lt-ref-self.rs:26:9
|
||||
|
|
||||
LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/lt-ref-self.rs:30:9
|
||||
|
|
||||
LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/lt-ref-self.rs:34:9
|
||||
|
|
||||
LL | fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
49
src/test/ui/self/elision/lt-self.rs
Normal file
49
src/test/ui/self/elision/lt-self.rs
Normal file
@ -0,0 +1,49 @@
|
||||
// run-pass
|
||||
|
||||
#![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> {
|
||||
fn take_self(self, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Self(self: Self, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Self(self: Box<Self>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Box_Self(self: Box<Box<Self>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Rc_Self(self: Rc<Self>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
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() { }
|
36
src/test/ui/self/elision/lt-struct.rs
Normal file
36
src/test/ui/self/elision/lt-struct.rs
Normal file
@ -0,0 +1,36 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
struct Struct<'a> { x: &'a u32 }
|
||||
|
||||
impl<'a> Struct<'a> {
|
||||
fn take_self(self, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Struct(self: Struct<'a>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Struct(self: Box<Struct<'a>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Box_Struct(self: Box<Box<Struct<'a>>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Rc_Struct(self: Rc<Struct<'a>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Rc_Struct(self: Box<Rc<Struct<'a>>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
39
src/test/ui/self/elision/ref-alias.rs
Normal file
39
src/test/ui/self/elision/ref-alias.rs
Normal file
@ -0,0 +1,39 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
type Alias = Struct;
|
||||
|
||||
impl Struct {
|
||||
// Test using an alias for `Struct`:
|
||||
//
|
||||
// FIXME. We currently fail to recognize this as the self type, which
|
||||
// feels like a bug.
|
||||
|
||||
fn ref_Alias(self: &Alias, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_ref_Alias(self: Box<&Alias>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn pin_ref_Alias(self: Pin<&Alias>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_box_ref_Alias(self: Box<Box<&Alias>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_pin_ref_Alias(self: Box<Pin<&Alias>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
32
src/test/ui/self/elision/ref-mut-alias.rs
Normal file
32
src/test/ui/self/elision/ref-mut-alias.rs
Normal file
@ -0,0 +1,32 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
type Alias = Struct;
|
||||
|
||||
impl Struct {
|
||||
// Test using an alias for `Struct`:
|
||||
|
||||
fn ref_Alias(self: &mut Alias, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_ref_Alias(self: Box<&mut Alias>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn pin_ref_Alias(self: Pin<&mut Alias>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_box_ref_Alias(self: Box<Box<&mut Alias>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn box_pin_ref_Alias(self: Box<Pin<&mut Alias>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
}
|
7
src/test/ui/self/elision/ref-mut-alias.stderr
Normal file
7
src/test/ui/self/elision/ref-mut-alias.stderr
Normal file
@ -0,0 +1,7 @@
|
||||
error[E0601]: `main` function not found in crate `ref_mut_alias`
|
||||
|
|
||||
= note: consider adding a `main` function to `$DIR/ref-mut-alias.rs`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0601`.
|
40
src/test/ui/self/elision/ref-mut-self.rs
Normal file
40
src/test/ui/self/elision/ref-mut-self.rs
Normal file
@ -0,0 +1,40 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
type Alias = Struct;
|
||||
|
||||
impl Struct {
|
||||
// Test using `&mut self` sugar:
|
||||
|
||||
fn ref_self(&mut self, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
// Test using `&mut Self` explicitly:
|
||||
|
||||
fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
62
src/test/ui/self/elision/ref-mut-self.stderr
Normal file
62
src/test/ui/self/elision/ref-mut-self.stderr
Normal file
@ -0,0 +1,62 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-self.rs:14:9
|
||||
|
|
||||
LL | fn ref_self(&mut self, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-self.rs:20:9
|
||||
|
|
||||
LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-self.rs:24:9
|
||||
|
|
||||
LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-self.rs:28:9
|
||||
|
|
||||
LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-self.rs:32:9
|
||||
|
|
||||
LL | fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-self.rs:36:9
|
||||
|
|
||||
LL | fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
34
src/test/ui/self/elision/ref-mut-struct.rs
Normal file
34
src/test/ui/self/elision/ref-mut-struct.rs
Normal file
@ -0,0 +1,34 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
type Alias = Struct;
|
||||
|
||||
impl Struct {
|
||||
// Test using `&mut Struct` explicitly:
|
||||
|
||||
fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
52
src/test/ui/self/elision/ref-mut-struct.stderr
Normal file
52
src/test/ui/self/elision/ref-mut-struct.stderr
Normal file
@ -0,0 +1,52 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-struct.rs:14:9
|
||||
|
|
||||
LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-struct.rs:18:9
|
||||
|
|
||||
LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-struct.rs:22:9
|
||||
|
|
||||
LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-struct.rs:26:9
|
||||
|
|
||||
LL | fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-mut-struct.rs:30:9
|
||||
|
|
||||
LL | fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
40
src/test/ui/self/elision/ref-self.rs
Normal file
40
src/test/ui/self/elision/ref-self.rs
Normal file
@ -0,0 +1,40 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
type Alias = Struct;
|
||||
|
||||
impl Struct {
|
||||
// Test using `&self` sugar:
|
||||
|
||||
fn ref_self(&self, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
// Test using `&Self` explicitly:
|
||||
|
||||
fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
62
src/test/ui/self/elision/ref-self.stderr
Normal file
62
src/test/ui/self/elision/ref-self.stderr
Normal file
@ -0,0 +1,62 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self.rs:14:9
|
||||
|
|
||||
LL | fn ref_self(&self, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self.rs:20:9
|
||||
|
|
||||
LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self.rs:24:9
|
||||
|
|
||||
LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self.rs:28:9
|
||||
|
|
||||
LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self.rs:32:9
|
||||
|
|
||||
LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-self.rs:36:9
|
||||
|
|
||||
LL | fn box_pin_ref_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
34
src/test/ui/self/elision/ref-struct.rs
Normal file
34
src/test/ui/self/elision/ref-struct.rs
Normal file
@ -0,0 +1,34 @@
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::pin::Pin;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
type Alias = Struct;
|
||||
|
||||
impl Struct {
|
||||
// Test using `&Struct` explicitly:
|
||||
|
||||
fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
52
src/test/ui/self/elision/ref-struct.stderr
Normal file
52
src/test/ui/self/elision/ref-struct.stderr
Normal file
@ -0,0 +1,52 @@
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-struct.rs:14:9
|
||||
|
|
||||
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-struct.rs:18:9
|
||||
|
|
||||
LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-struct.rs:22:9
|
||||
|
|
||||
LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-struct.rs:26:9
|
||||
|
|
||||
LL | fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/ref-struct.rs:30:9
|
||||
|
|
||||
LL | fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
|
||||
| ---- ----
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
LL | f
|
||||
| ^ ...but data from `f` is returned here
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
36
src/test/ui/self/elision/self.rs
Normal file
36
src/test/ui/self/elision/self.rs
Normal file
@ -0,0 +1,36 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
impl Struct {
|
||||
fn take_self(self, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Self(self: Self, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Self(self: Box<Self>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Box_Self(self: Box<Box<Self>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Rc_Self(self: Rc<Self>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
|
||||
fn take_Box_Rc_Self(self: Box<Rc<Self>>, f: &u32) -> &u32 {
|
||||
f
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
34
src/test/ui/self/elision/struct.rs
Normal file
34
src/test/ui/self/elision/struct.rs
Normal file
@ -0,0 +1,34 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(arbitrary_self_types)]
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
struct Struct { }
|
||||
|
||||
impl Struct {
|
||||
// Test using `&mut Struct` explicitly:
|
||||
|
||||
fn ref_Struct(self: Struct, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_Struct(self: Box<Struct>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn rc_Struct(self: Rc<Struct>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_box_Struct(self: Box<Box<Struct>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
|
||||
fn box_rc_Struct(self: Box<Rc<Struct>>, f: &u32) -> &u32 {
|
||||
f //~ ERROR lifetime mismatch
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
Loading…
Reference in New Issue
Block a user