Skip to content

Commit dc04a4e

Browse files
committed
Minor clean up
1 parent 857a8dd commit dc04a4e

10 files changed

+27
-36
lines changed

src/test/ui/self/elision/README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Test cases intended to to document behavior and try to exhaustively
2-
explore the combinations.
2+
explore the combinations.
33

44
## Confidence
55

@@ -23,11 +23,11 @@ in the "confidence" field in the following table. Values:
2323
| `struct.rs` | `Struct` | `Struct` | ignore `self` parameter | 100% |
2424
| `alias.rs` | `Struct` | `Alias` | ignore `self` parameter | 100% |
2525
| `ref-self.rs` | `Struct` | `&Self` | take lifetime from `&Self` | 100% |
26-
| `ref-mut-self.rs` | `Struct` | `&mut Self` | take lifetime from `&Self` | 100% |
26+
| `ref-mut-self.rs` | `Struct` | `&mut Self` | take lifetime from `&mut Self` | 100% |
2727
| `ref-struct.rs` | `Struct` | `&Struct` | take lifetime from `&Self` | 50% |
28-
| `ref-mut-struct.rs` | `Struct` | `&Struct` | take lifetime from `&Self` | 50% |
28+
| `ref-mut-struct.rs` | `Struct` | `&mut Struct` | take lifetime from `&mut Self` | 50% |
2929
| `ref-alias.rs` | `Struct` | `&Alias` | ignore `Alias` | 0% |
30-
| `ref-mut-alias.rs` | `Struct` | `&Alias` | ignore `Alias` | 0% |
30+
| `ref-mut-alias.rs` | `Struct` | `&mut Alias` | ignore `Alias` | 0% |
3131
| `lt-self.rs` | `Struct<'a>` | `Self` | ignore `Self` (and hence `'a`) | 25% |
3232
| `lt-struct.rs` | `Struct<'a>` | `Self` | ignore `Self` (and hence `'a`) | 0% |
3333
| `lt-alias.rs` | `Alias<'a>` | `Self` | ignore `Self` (and hence `'a`) | 0% |
@@ -42,4 +42,3 @@ In each case, we test the following patterns:
4242
- `self: Box<Pin<XXX>>`
4343

4444
In the non-reference cases, `Pin` causes errors so we substitute `Rc`.
45-

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

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use std::pin::Pin;
55

66
struct Struct { }
77

8-
type Alias = Struct;
9-
108
impl Struct {
119
// Test using `&mut self` sugar:
1210

src/test/ui/self/elision/ref-mut-self.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/ref-mut-self.rs:14:9
2+
--> $DIR/ref-mut-self.rs:12:9
33
|
44
LL | fn ref_self(&mut self, f: &u32) -> &u32 {
55
| ---- ----
@@ -9,7 +9,7 @@ LL | f
99
| ^ ...but data from `f` is returned here
1010

1111
error[E0623]: lifetime mismatch
12-
--> $DIR/ref-mut-self.rs:20:9
12+
--> $DIR/ref-mut-self.rs:18:9
1313
|
1414
LL | fn ref_Self(self: &mut Self, f: &u32) -> &u32 {
1515
| ---- ----
@@ -19,7 +19,7 @@ LL | f
1919
| ^ ...but data from `f` is returned here
2020

2121
error[E0623]: lifetime mismatch
22-
--> $DIR/ref-mut-self.rs:24:9
22+
--> $DIR/ref-mut-self.rs:22:9
2323
|
2424
LL | fn box_ref_Self(self: Box<&mut Self>, f: &u32) -> &u32 {
2525
| ---- ----
@@ -29,7 +29,7 @@ LL | f
2929
| ^ ...but data from `f` is returned here
3030

3131
error[E0623]: lifetime mismatch
32-
--> $DIR/ref-mut-self.rs:28:9
32+
--> $DIR/ref-mut-self.rs:26:9
3333
|
3434
LL | fn pin_ref_Self(self: Pin<&mut Self>, f: &u32) -> &u32 {
3535
| ---- ----
@@ -39,7 +39,7 @@ LL | f
3939
| ^ ...but data from `f` is returned here
4040

4141
error[E0623]: lifetime mismatch
42-
--> $DIR/ref-mut-self.rs:32:9
42+
--> $DIR/ref-mut-self.rs:30:9
4343
|
4444
LL | fn box_box_ref_Self(self: Box<Box<&mut Self>>, f: &u32) -> &u32 {
4545
| ---- ----
@@ -49,7 +49,7 @@ LL | f
4949
| ^ ...but data from `f` is returned here
5050

5151
error[E0623]: lifetime mismatch
52-
--> $DIR/ref-mut-self.rs:36:9
52+
--> $DIR/ref-mut-self.rs:34:9
5353
|
5454
LL | fn box_pin_ref_Self(self: Box<Pin<&mut Self>>, f: &u32) -> &u32 {
5555
| ---- ----

src/test/ui/self/elision/ref-mut-struct.rs

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use std::pin::Pin;
55

66
struct Struct { }
77

8-
type Alias = Struct;
9-
108
impl Struct {
119
// Test using `&mut Struct` explicitly:
1210

src/test/ui/self/elision/ref-mut-struct.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/ref-mut-struct.rs:14:9
2+
--> $DIR/ref-mut-struct.rs:12:9
33
|
44
LL | fn ref_Struct(self: &mut Struct, f: &u32) -> &u32 {
55
| ---- ----
@@ -9,7 +9,7 @@ LL | f
99
| ^ ...but data from `f` is returned here
1010

1111
error[E0623]: lifetime mismatch
12-
--> $DIR/ref-mut-struct.rs:18:9
12+
--> $DIR/ref-mut-struct.rs:16:9
1313
|
1414
LL | fn box_ref_Struct(self: Box<&mut Struct>, f: &u32) -> &u32 {
1515
| ---- ----
@@ -19,7 +19,7 @@ LL | f
1919
| ^ ...but data from `f` is returned here
2020

2121
error[E0623]: lifetime mismatch
22-
--> $DIR/ref-mut-struct.rs:22:9
22+
--> $DIR/ref-mut-struct.rs:20:9
2323
|
2424
LL | fn pin_ref_Struct(self: Pin<&mut Struct>, f: &u32) -> &u32 {
2525
| ---- ----
@@ -29,7 +29,7 @@ LL | f
2929
| ^ ...but data from `f` is returned here
3030

3131
error[E0623]: lifetime mismatch
32-
--> $DIR/ref-mut-struct.rs:26:9
32+
--> $DIR/ref-mut-struct.rs:24:9
3333
|
3434
LL | fn box_box_ref_Struct(self: Box<Box<&mut Struct>>, f: &u32) -> &u32 {
3535
| ---- ----
@@ -39,7 +39,7 @@ LL | f
3939
| ^ ...but data from `f` is returned here
4040

4141
error[E0623]: lifetime mismatch
42-
--> $DIR/ref-mut-struct.rs:30:9
42+
--> $DIR/ref-mut-struct.rs:28:9
4343
|
4444
LL | fn box_pin_ref_Struct(self: Box<Pin<&mut Struct>>, f: &u32) -> &u32 {
4545
| ---- ----

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

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use std::pin::Pin;
55

66
struct Struct { }
77

8-
type Alias = Struct;
9-
108
impl Struct {
119
// Test using `&self` sugar:
1210

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

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use std::pin::Pin;
55

66
struct Struct { }
77

8-
type Alias = Struct;
9-
108
impl Struct {
119
// Test using `&Struct` explicitly:
1210

src/test/ui/self/elision/ref-struct.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/ref-struct.rs:14:9
2+
--> $DIR/ref-struct.rs:12:9
33
|
44
LL | fn ref_Struct(self: &Struct, f: &u32) -> &u32 {
55
| ---- ----
@@ -9,7 +9,7 @@ LL | f
99
| ^ ...but data from `f` is returned here
1010

1111
error[E0623]: lifetime mismatch
12-
--> $DIR/ref-struct.rs:18:9
12+
--> $DIR/ref-struct.rs:16:9
1313
|
1414
LL | fn box_ref_Struct(self: Box<&Struct>, f: &u32) -> &u32 {
1515
| ---- ----
@@ -19,7 +19,7 @@ LL | f
1919
| ^ ...but data from `f` is returned here
2020

2121
error[E0623]: lifetime mismatch
22-
--> $DIR/ref-struct.rs:22:9
22+
--> $DIR/ref-struct.rs:20:9
2323
|
2424
LL | fn pin_ref_Struct(self: Pin<&Struct>, f: &u32) -> &u32 {
2525
| ---- ----
@@ -29,7 +29,7 @@ LL | f
2929
| ^ ...but data from `f` is returned here
3030

3131
error[E0623]: lifetime mismatch
32-
--> $DIR/ref-struct.rs:26:9
32+
--> $DIR/ref-struct.rs:24:9
3333
|
3434
LL | fn box_box_ref_Struct(self: Box<Box<&Struct>>, f: &u32) -> &u32 {
3535
| ---- ----
@@ -39,7 +39,7 @@ LL | f
3939
| ^ ...but data from `f` is returned here
4040

4141
error[E0623]: lifetime mismatch
42-
--> $DIR/ref-struct.rs:30:9
42+
--> $DIR/ref-struct.rs:28:9
4343
|
4444
LL | fn box_pin_Struct(self: Box<Pin<&Struct>>, f: &u32) -> &u32 {
4545
| ---- ----

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

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,24 @@ use std::rc::Rc;
88
struct Struct { }
99

1010
impl Struct {
11-
// Test using `&mut Struct` explicitly:
12-
1311
fn ref_Struct(self: Struct, f: &u32) -> &u32 {
14-
f //~ ERROR lifetime mismatch
12+
f
1513
}
1614

1715
fn box_Struct(self: Box<Struct>, f: &u32) -> &u32 {
18-
f //~ ERROR lifetime mismatch
16+
f
1917
}
2018

2119
fn rc_Struct(self: Rc<Struct>, f: &u32) -> &u32 {
22-
f //~ ERROR lifetime mismatch
20+
f
2321
}
2422

2523
fn box_box_Struct(self: Box<Box<Struct>>, f: &u32) -> &u32 {
26-
f //~ ERROR lifetime mismatch
24+
f
2725
}
2826

2927
fn box_rc_Struct(self: Box<Rc<Struct>>, f: &u32) -> &u32 {
30-
f //~ ERROR lifetime mismatch
28+
f
3129
}
3230
}
3331

src/test/ui/self/self_lifetime.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// check-pass
22

3+
// https://github.com/rust-lang/rust/pull/60944#issuecomment-495346120
4+
35
struct Foo<'a>(&'a ());
46
impl<'a> Foo<'a> {
57
fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }

0 commit comments

Comments
 (0)