Skip to content

Commit 1289cfe

Browse files
committed
Run rustfmt on modified tests
1 parent 79ea5e7 commit 1289cfe

23 files changed

+122
-110
lines changed

tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.fixed

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ struct Foo {
55
}
66

77
impl Foo {
8-
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
9-
10-
x
11-
//~^ ERROR lifetime may not live long enough
12-
13-
}
14-
8+
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
9+
x
10+
//~^ ERROR lifetime may not live long enough
11+
}
1512
}
1613

1714
fn main() {}

tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-return-type-is-anon.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ struct Foo {
55
}
66

77
impl Foo {
8-
fn foo<'a>(&self, x: &'a i32) -> &i32 {
9-
10-
x
11-
//~^ ERROR lifetime may not live long enough
12-
13-
}
14-
8+
fn foo<'a>(&self, x: &'a i32) -> &i32 {
9+
x
10+
//~^ ERROR lifetime may not live long enough
11+
}
1512
}
1613

1714
fn main() {}
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:10:5
2+
--> $DIR/ex1-return-one-existing-name-return-type-is-anon.rs:9:9
33
|
4-
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
5-
| -- - let's call the lifetime of this reference `'1`
6-
| |
7-
| lifetime `'a` defined here
8-
LL |
9-
LL | x
10-
| ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
4+
LL | fn foo<'a>(&self, x: &'a i32) -> &i32 {
5+
| -- - let's call the lifetime of this reference `'1`
6+
| |
7+
| lifetime `'a` defined here
8+
LL | x
9+
| ^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
1110
|
1211
help: consider introducing a named lifetime parameter and update trait if needed
1312
|
14-
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
15-
| ++ ++
13+
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
14+
| ++ ++
1615

1716
error: aborting due to 1 previous error
1817

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//@ run-rustfix
22
#![allow(dead_code)]
33
struct Foo {
4-
field: i32,
4+
field: i32,
55
}
66

77
impl Foo {
8-
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
9-
x
10-
//~^ ERROR lifetime may not live long enough
11-
}
8+
fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
9+
x
10+
//~^ ERROR lifetime may not live long enough
11+
}
1212
}
1313

14-
fn main() { }
14+
fn main() {}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//@ run-rustfix
22
#![allow(dead_code)]
33
struct Foo {
4-
field: i32,
4+
field: i32,
55
}
66

77
impl Foo {
8-
fn foo<'a>(&self, x: &i32) -> &i32 {
9-
x
10-
//~^ ERROR lifetime may not live long enough
11-
}
8+
fn foo<'a>(&self, x: &i32) -> &i32 {
9+
x
10+
//~^ ERROR lifetime may not live long enough
11+
}
1212
}
1313

14-
fn main() { }
14+
fn main() {}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error: lifetime may not live long enough
2-
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:5
2+
--> $DIR/ex3-both-anon-regions-return-type-is-anon.rs:9:9
33
|
4-
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
5-
| - - let's call the lifetime of this reference `'1`
6-
| |
7-
| let's call the lifetime of this reference `'2`
8-
LL | x
9-
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
4+
LL | fn foo<'a>(&self, x: &i32) -> &i32 {
5+
| - - let's call the lifetime of this reference `'1`
6+
| |
7+
| let's call the lifetime of this reference `'2`
8+
LL | x
9+
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
1010
|
1111
help: consider introducing a named lifetime parameter and update trait if needed
1212
|
13-
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
14-
| ++ ++ ++
13+
LL | fn foo<'a>(&'a self, x: &'a i32) -> &'a i32 {
14+
| ++ ++ ++
1515

1616
error: aborting due to 1 previous error
1717

tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@ use std::pin::Pin;
33
struct Foo;
44

55
impl Foo {
6-
fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
7-
//~^ lifetime may not live long enough
6+
fn a(self: Pin<&Foo>, f: &Foo) -> &Foo {
7+
f //~ ERROR lifetime may not live long enough
8+
}
89

910
// For this suggestion to be right, we'd need to also suggest `self: Pin<&'a Self>`, which we
1011
// don't, but we provide a follow up suggestion to do so, so I condider that good at least for
1112
// now.
12-
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
13-
//~^ lifetime may not live long enough
13+
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) {
14+
(self, f) //~ ERROR lifetime may not live long enough
15+
}
1416
}
1517

1618
type Alias<T> = Pin<T>;
1719
impl Foo {
18-
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
19-
//~^ lifetime may not live long enough
20+
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() {
21+
arg //~ ERROR lifetime may not live long enough
22+
}
2023
}
2124

2225
fn main() {}

tests/ui/self/arbitrary_self_types_pin_lifetime_mismatch.stderr

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,46 @@
11
error: lifetime may not live long enough
2-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:6:46
2+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:7:9
33
|
4-
LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo { f }
5-
| - - ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
6-
| | |
7-
| | let's call the lifetime of this reference `'1`
4+
LL | fn a(self: Pin<&Foo>, f: &Foo) -> &Foo {
5+
| - - let's call the lifetime of this reference `'1`
6+
| |
87
| let's call the lifetime of this reference `'2`
8+
LL | f
9+
| ^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
910
|
1011
help: consider introducing a named lifetime parameter and update trait if needed
1112
|
12-
LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo { f }
13+
LL | fn a<'a>(self: Pin<&'a Foo>, f: &'a Foo) -> &'a Foo {
1314
| ++++ ++ ++ ++
1415

1516
error: lifetime may not live long enough
16-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:12:69
17+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:14:9
1718
|
18-
LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) }
19-
| - - ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
20-
| | |
21-
| | let's call the lifetime of this reference `'1`
19+
LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) {
20+
| - - let's call the lifetime of this reference `'1`
21+
| |
2222
| let's call the lifetime of this reference `'2`
23+
LL | (self, f)
24+
| ^^^^^^^^^ method was supposed to return data with lifetime `'2` but it is returning data with lifetime `'1`
2325
|
2426
help: consider introducing a named lifetime parameter and update trait if needed
2527
|
26-
LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) { (self, f) }
28+
LL | fn c<'a>(self: Pin<&'a Self>, f: &'a Foo, g: &Foo) -> (Pin<&'a Foo>, &'a Foo) {
2729
| ++++ ++ ++ ++ ++
2830

2931
error: lifetime may not live long enough
30-
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:18:58
32+
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:21:9
3133
|
32-
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
33-
| -- ---- has type `Pin<&'1 Foo>` ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
34+
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() {
35+
| -- ---- has type `Pin<&'1 Foo>`
3436
| |
3537
| lifetime `'a` defined here
38+
LL | arg
39+
| ^^^ method was supposed to return data with lifetime `'1` but it is returning data with lifetime `'a`
3640
|
3741
help: consider introducing a named lifetime parameter and update trait if needed
3842
|
39-
LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () { arg }
43+
LL | fn bar<'a>(self: Alias<&'a Self>, arg: &'a ()) -> &'a () {
4044
| ++ ++
4145

4246
error: aborting due to 3 previous errors

tests/ui/self/elision/lt-ref-self-async.fixed

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use std::pin::Pin;
66

7-
struct Struct<'a> { data: &'a u32 }
7+
struct Struct<'a> {
8+
data: &'a u32,
9+
}
810

911
impl<'a> Struct<'a> {
1012
// Test using `&self` sugar:
@@ -42,4 +44,4 @@ impl<'a> Struct<'a> {
4244
}
4345
}
4446

45-
fn main() { }
47+
fn main() {}

tests/ui/self/elision/lt-ref-self-async.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
use std::pin::Pin;
66

7-
struct Struct<'a> { data: &'a u32 }
7+
struct Struct<'a> {
8+
data: &'a u32,
9+
}
810

911
impl<'a> Struct<'a> {
1012
// Test using `&self` sugar:
@@ -42,4 +44,4 @@ impl<'a> Struct<'a> {
4244
}
4345
}
4446

45-
fn main() { }
47+
fn main() {}

tests/ui/self/elision/lt-ref-self-async.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/lt-ref-self-async.rs:13:9
2+
--> $DIR/lt-ref-self-async.rs:15:9
33
|
44
LL | async fn ref_self(&self, f: &u32) -> &u32 {
55
| - - let's call the lifetime of this reference `'1`
@@ -14,7 +14,7 @@ LL | async fn ref_self<'b>(&'b self, f: &'b u32) -> &u32 {
1414
| ++++ ++ ++
1515

1616
error: lifetime may not live long enough
17-
--> $DIR/lt-ref-self-async.rs:20:9
17+
--> $DIR/lt-ref-self-async.rs:22:9
1818
|
1919
LL | async fn ref_Self(self: &Self, f: &u32) -> &u32 {
2020
| - - let's call the lifetime of this reference `'1`
@@ -29,7 +29,7 @@ LL | async fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &u32 {
2929
| ++++ ++ ++
3030

3131
error: lifetime may not live long enough
32-
--> $DIR/lt-ref-self-async.rs:25:9
32+
--> $DIR/lt-ref-self-async.rs:27:9
3333
|
3434
LL | async fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
3535
| - - let's call the lifetime of this reference `'1`
@@ -44,7 +44,7 @@ LL | async fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &u32 {
4444
| ++++ ++ ++
4545

4646
error: lifetime may not live long enough
47-
--> $DIR/lt-ref-self-async.rs:30:9
47+
--> $DIR/lt-ref-self-async.rs:32:9
4848
|
4949
LL | async fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
5050
| - - let's call the lifetime of this reference `'1`
@@ -59,7 +59,7 @@ LL | async fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &u32 {
5959
| ++++ ++ ++
6060

6161
error: lifetime may not live long enough
62-
--> $DIR/lt-ref-self-async.rs:35:9
62+
--> $DIR/lt-ref-self-async.rs:37:9
6363
|
6464
LL | async fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
6565
| - - let's call the lifetime of this reference `'1`
@@ -74,7 +74,7 @@ LL | async fn box_box_ref_Self<'b>(self: Box<Box<&'b Self>>, f: &'b u32) ->
7474
| ++++ ++ ++
7575

7676
error: lifetime may not live long enough
77-
--> $DIR/lt-ref-self-async.rs:40:9
77+
--> $DIR/lt-ref-self-async.rs:42:9
7878
|
7979
LL | async fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
8080
| - - let's call the lifetime of this reference `'1`

tests/ui/self/elision/lt-ref-self.fixed

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use std::pin::Pin;
55

6-
struct Struct<'a> { data: &'a u32 }
6+
struct Struct<'a> {
7+
data: &'a u32,
8+
}
79

810
impl<'a> Struct<'a> {
911
// Test using `&self` sugar:
@@ -41,4 +43,4 @@ impl<'a> Struct<'a> {
4143
}
4244
}
4345

44-
fn main() { }
46+
fn main() {}

tests/ui/self/elision/lt-ref-self.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
use std::pin::Pin;
55

6-
struct Struct<'a> { data: &'a u32 }
6+
struct Struct<'a> {
7+
data: &'a u32,
8+
}
79

810
impl<'a> Struct<'a> {
911
// Test using `&self` sugar:
@@ -41,4 +43,4 @@ impl<'a> Struct<'a> {
4143
}
4244
}
4345

44-
fn main() { }
46+
fn main() {}

tests/ui/self/elision/lt-ref-self.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: lifetime may not live long enough
2-
--> $DIR/lt-ref-self.rs:12:9
2+
--> $DIR/lt-ref-self.rs:14:9
33
|
44
LL | fn ref_self(&self, f: &u32) -> &u32 {
55
| - - let's call the lifetime of this reference `'1`
@@ -14,7 +14,7 @@ LL | fn ref_self<'b>(&'b self, f: &'b u32) -> &'b u32 {
1414
| ++++ ++ ++ ++
1515

1616
error: lifetime may not live long enough
17-
--> $DIR/lt-ref-self.rs:19:9
17+
--> $DIR/lt-ref-self.rs:21:9
1818
|
1919
LL | fn ref_Self(self: &Self, f: &u32) -> &u32 {
2020
| - - let's call the lifetime of this reference `'1`
@@ -29,7 +29,7 @@ LL | fn ref_Self<'b>(self: &'b Self, f: &'b u32) -> &'b u32 {
2929
| ++++ ++ ++ ++
3030

3131
error: lifetime may not live long enough
32-
--> $DIR/lt-ref-self.rs:24:9
32+
--> $DIR/lt-ref-self.rs:26:9
3333
|
3434
LL | fn box_ref_Self(self: Box<&Self>, f: &u32) -> &u32 {
3535
| - - let's call the lifetime of this reference `'1`
@@ -44,7 +44,7 @@ LL | fn box_ref_Self<'b>(self: Box<&'b Self>, f: &'b u32) -> &'b u32 {
4444
| ++++ ++ ++ ++
4545

4646
error: lifetime may not live long enough
47-
--> $DIR/lt-ref-self.rs:29:9
47+
--> $DIR/lt-ref-self.rs:31:9
4848
|
4949
LL | fn pin_ref_Self(self: Pin<&Self>, f: &u32) -> &u32 {
5050
| - - let's call the lifetime of this reference `'1`
@@ -59,7 +59,7 @@ LL | fn pin_ref_Self<'b>(self: Pin<&'b Self>, f: &'b u32) -> &'b u32 {
5959
| ++++ ++ ++ ++
6060

6161
error: lifetime may not live long enough
62-
--> $DIR/lt-ref-self.rs:34:9
62+
--> $DIR/lt-ref-self.rs:36:9
6363
|
6464
LL | fn box_box_ref_Self(self: Box<Box<&Self>>, f: &u32) -> &u32 {
6565
| - - let's call the lifetime of this reference `'1`
@@ -74,7 +74,7 @@ LL | fn box_box_ref_Self<'b>(self: Box<Box<&'b Self>>, f: &'b u32) -> &'b u3
7474
| ++++ ++ ++ ++
7575

7676
error: lifetime may not live long enough
77-
--> $DIR/lt-ref-self.rs:39:9
77+
--> $DIR/lt-ref-self.rs:41:9
7878
|
7979
LL | fn box_pin_Self(self: Box<Pin<&Self>>, f: &u32) -> &u32 {
8080
| - - let's call the lifetime of this reference `'1`

0 commit comments

Comments
 (0)