1
Fork 0

Minor clean up

This commit is contained in:
Taiki Endo 2019-07-16 00:48:28 +09:00
parent c1f22c018e
commit aab9edc68a
10 changed files with 27 additions and 36 deletions

View file

@ -1,5 +1,5 @@
Test cases intended to to document behavior and try to exhaustively
explore the combinations.
explore the combinations.
## Confidence
@ -23,11 +23,11 @@ in the "confidence" field in the following table. Values:
| `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-mut-self.rs` | `Struct` | `&mut Self` | take lifetime from `&mut Self` | 100% |
| `ref-struct.rs` | `Struct` | `&Struct` | take lifetime from `&Self` | 50% |
| `ref-mut-struct.rs` | `Struct` | `&Struct` | take lifetime from `&Self` | 50% |
| `ref-mut-struct.rs` | `Struct` | `&mut Struct` | take lifetime from `&mut Self` | 50% |
| `ref-alias.rs` | `Struct` | `&Alias` | ignore `Alias` | 0% |
| `ref-mut-alias.rs` | `Struct` | `&Alias` | ignore `Alias` | 0% |
| `ref-mut-alias.rs` | `Struct` | `&mut 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% |
@ -42,4 +42,3 @@ In each case, we test the following patterns:
- `self: Box<Pin<XXX>>`
In the non-reference cases, `Pin` causes errors so we substitute `Rc`.

View file

@ -5,8 +5,6 @@ use std::pin::Pin;
struct Struct { }
type Alias = Struct;
impl Struct {
// Test using `&mut self` sugar:

View file

@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self.rs:14:9
--> $DIR/ref-mut-self.rs:12:9
|
LL | fn ref_self(&mut self, f: &u32) -> &u32 {
| ---- ----
@ -9,7 +9,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self.rs:20:9
--> $DIR/ref-mut-self.rs:18:9
|
LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
| ---- ----
@ -19,7 +19,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self.rs:24:9
--> $DIR/ref-mut-self.rs:22:9
|
LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
| ---- ----
@ -29,7 +29,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self.rs:28:9
--> $DIR/ref-mut-self.rs:26:9
|
LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
| ---- ----
@ -39,7 +39,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self.rs:32:9
--> $DIR/ref-mut-self.rs:30:9
|
LL | fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
| ---- ----
@ -49,7 +49,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-self.rs:36:9
--> $DIR/ref-mut-self.rs:34:9
|
LL | fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
| ---- ----

View file

@ -5,8 +5,6 @@ use std::pin::Pin;
struct Struct { }
type Alias = Struct;
impl Struct {
// Test using `&mut Struct` explicitly:

View file

@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct.rs:14:9
--> $DIR/ref-mut-struct.rs:12:9
|
LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
| ---- ----
@ -9,7 +9,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct.rs:18:9
--> $DIR/ref-mut-struct.rs:16:9
|
LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
| ---- ----
@ -19,7 +19,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct.rs:22:9
--> $DIR/ref-mut-struct.rs:20:9
|
LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
| ---- ----
@ -29,7 +29,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct.rs:26:9
--> $DIR/ref-mut-struct.rs:24:9
|
LL | fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
| ---- ----
@ -39,7 +39,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-mut-struct.rs:30:9
--> $DIR/ref-mut-struct.rs:28:9
|
LL | fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
| ---- ----

View file

@ -5,8 +5,6 @@ use std::pin::Pin;
struct Struct { }
type Alias = Struct;
impl Struct {
// Test using `&self` sugar:

View file

@ -5,8 +5,6 @@ use std::pin::Pin;
struct Struct { }
type Alias = Struct;
impl Struct {
// Test using `&Struct` explicitly:

View file

@ -1,5 +1,5 @@
error[E0623]: lifetime mismatch
--> $DIR/ref-struct.rs:14:9
--> $DIR/ref-struct.rs:12:9
|
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
| ---- ----
@ -9,7 +9,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-struct.rs:18:9
--> $DIR/ref-struct.rs:16:9
|
LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
| ---- ----
@ -19,7 +19,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-struct.rs:22:9
--> $DIR/ref-struct.rs:20:9
|
LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
| ---- ----
@ -29,7 +29,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-struct.rs:26:9
--> $DIR/ref-struct.rs:24:9
|
LL | fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
| ---- ----
@ -39,7 +39,7 @@ LL | f
| ^ ...but data from `f` is returned here
error[E0623]: lifetime mismatch
--> $DIR/ref-struct.rs:30:9
--> $DIR/ref-struct.rs:28:9
|
LL | fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
| ---- ----

View file

@ -8,26 +8,24 @@ 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
f
}
fn box_Struct(self: Box<Struct>, f: &u32) -> &u32 {
f //~ ERROR lifetime mismatch
f
}
fn rc_Struct(self: Rc<Struct>, f: &u32) -> &u32 {
f //~ ERROR lifetime mismatch
f
}
fn box_box_Struct(self: Box<Box<Struct>>, f: &u32) -> &u32 {
f //~ ERROR lifetime mismatch
f
}
fn box_rc_Struct(self: Box<Rc<Struct>>, f: &u32) -> &u32 {
f //~ ERROR lifetime mismatch
f
}
}

View file

@ -1,5 +1,7 @@
// check-pass
// https://github.com/rust-lang/rust/pull/60944#issuecomment-495346120
struct Foo<'a>(&'a ());
impl<'a> Foo<'a> {
fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }