Skip to content

Commit f337a79

Browse files
committed
update tests
Signed-off-by: Zhi Qi <qizhi@pingcap.com>
1 parent c40ec11 commit f337a79

16 files changed

+56
-99
lines changed

tests/ui/impl-trait/equal-hidden-lifetimes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
// `'a == 'static` so `&'a i32` is fine as the return type
77
fn equal_regions_static<'a: 'static>(x: &'a i32) -> impl Sized {
8-
//~^ WARNING unnecessary lifetime parameter `'a`
98
x
109
}
1110

tests/ui/impl-trait/equal-hidden-lifetimes.stderr

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/ui/issues/issue-30438-c.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ trait Trait { type Out; }
55
struct Test<'a> { s: &'a str }
66

77
fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static {
8-
//~^ WARN unnecessary lifetime parameter `'z`
98
let x = Test { s: "this cannot last" };
109
&x
1110
//~^ ERROR: cannot return reference to local variable `x`

tests/ui/issues/issue-30438-c.stderr

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
warning: unnecessary lifetime parameter `'z`
2-
--> $DIR/issue-30438-c.rs:7:74
3-
|
4-
LL | fn silly<'y, 'z>(_s: &'y Test<'z>) -> &'y <Test<'z> as Trait>::Out where 'z: 'static {
5-
| ^^
6-
|
7-
= note: `#[warn(named_static_lifetimes)]` on by default
8-
= help: you can use the `'static` lifetime directly, in place of `'z`
9-
101
error[E0515]: cannot return reference to local variable `x`
11-
--> $DIR/issue-30438-c.rs:10:5
2+
--> $DIR/issue-30438-c.rs:9:5
123
|
134
LL | &x
145
| ^^ returns a reference to data owned by the current function
156

16-
error: aborting due to previous error; 1 warning emitted
7+
error: aborting due to previous error
178

189
For more information about this error, try `rustc --explain E0515`.

tests/ui/regions/regions-free-region-outlives-static-outlives-free-region.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//
99
// 'a : 'b
1010

11+
#![warn(unused_lifetimes)]
12+
1113
fn test<'a,'b>(x: &'a i32) -> &'b i32
1214
where 'a: 'static //~ WARN unnecessary lifetime parameter `'a`
1315
{

tests/ui/regions/regions-free-region-outlives-static-outlives-free-region.stderr

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
warning: unnecessary lifetime parameter `'a`
2-
--> $DIR/regions-free-region-outlives-static-outlives-free-region.rs:12:11
2+
--> $DIR/regions-free-region-outlives-static-outlives-free-region.rs:14:11
33
|
44
LL | where 'a: 'static
55
| ^^
66
|
7-
= note: `#[warn(named_static_lifetimes)]` on by default
87
= help: you can use the `'static` lifetime directly, in place of `'a`
8+
note: the lint level is defined here
9+
--> $DIR/regions-free-region-outlives-static-outlives-free-region.rs:11:9
10+
|
11+
LL | #![warn(unused_lifetimes)]
12+
| ^^^^^^^^^^^^^^^^
913

1014
warning: 1 warning emitted
11-

tests/ui/regions/regions-static-bound-rpass.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// run-pass
22

3+
#![warn(unused_lifetimes)]
4+
35
fn invariant_id<'a,'b>(t: &'b mut &'static ()) -> &'b mut &'a ()
46
where 'a: 'static { t }
57
//~^ WARN unnecessary lifetime parameter `'a`

tests/ui/regions/regions-static-bound-rpass.stderr

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
warning: unnecessary lifetime parameter `'a`
2-
--> $DIR/regions-static-bound-rpass.rs:4:11
2+
--> $DIR/regions-static-bound-rpass.rs:6:11
33
|
44
LL | where 'a: 'static { t }
55
| ^^
66
|
7-
= note: `#[warn(named_static_lifetimes)]` on by default
87
= help: you can use the `'static` lifetime directly, in place of `'a`
8+
note: the lint level is defined here
9+
--> $DIR/regions-static-bound-rpass.rs:3:9
10+
|
11+
LL | #![warn(unused_lifetimes)]
12+
| ^^^^^^^^^^^^^^^^
913

1014
warning: unnecessary lifetime parameter `'a`
11-
--> $DIR/regions-static-bound-rpass.rs:8:11
15+
--> $DIR/regions-static-bound-rpass.rs:10:11
1216
|
1317
LL | where 'a: 'static { t }
1418
| ^^
1519
|
1620
= help: you can use the `'static` lifetime directly, in place of `'a`
1721

1822
warning: unnecessary lifetime parameter `'b`
19-
--> $DIR/regions-static-bound-rpass.rs:12:19
23+
--> $DIR/regions-static-bound-rpass.rs:14:19
2024
|
2125
LL | where 'a: 'b, 'b: 'static { t }
2226
| ^^
2327
|
2428
= help: you can use the `'static` lifetime directly, in place of `'b`
2529

2630
warning: 3 warnings emitted
27-

tests/ui/regions/regions-static-bound.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
fn static_id<'a,'b>(t: &'a ()) -> &'static ()
2-
where 'a: 'static { t }
3-
//~^ WARN unnecessary lifetime parameter `'a`
1+
#![warn(unused_lifetimes)]
2+
3+
fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
4+
//~^ WARN lifetime parameter `'b` never used
5+
//~| WARN unnecessary lifetime parameter `'a`
46

57
fn static_id_indirect<'a,'b>(t: &'a ()) -> &'static ()
68
where 'a: 'b, 'b: 'static { t }

tests/ui/regions/regions-static-bound.stderr

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,43 @@
1+
warning: lifetime parameter `'b` never used
2+
--> $DIR/regions-static-bound.rs:3:17
3+
|
4+
LL | fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
5+
| -^^
6+
| |
7+
| help: elide the unused lifetime
8+
|
9+
note: the lint level is defined here
10+
--> $DIR/regions-static-bound.rs:1:9
11+
|
12+
LL | #![warn(unused_lifetimes)]
13+
| ^^^^^^^^^^^^^^^^
14+
115
warning: unnecessary lifetime parameter `'a`
2-
--> $DIR/regions-static-bound.rs:2:11
16+
--> $DIR/regions-static-bound.rs:3:53
317
|
4-
LL | where 'a: 'static { t }
5-
| ^^
18+
LL | fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
19+
| ^^
620
|
7-
= note: `#[warn(named_static_lifetimes)]` on by default
821
= help: you can use the `'static` lifetime directly, in place of `'a`
922

1023
warning: unnecessary lifetime parameter `'b`
11-
--> $DIR/regions-static-bound.rs:6:19
24+
--> $DIR/regions-static-bound.rs:8:19
1225
|
1326
LL | where 'a: 'b, 'b: 'static { t }
1427
| ^^
1528
|
1629
= help: you can use the `'static` lifetime directly, in place of `'b`
1730

1831
error: lifetime may not live long enough
19-
--> $DIR/regions-static-bound.rs:10:5
32+
--> $DIR/regions-static-bound.rs:12:5
2033
|
2134
LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
2235
| -- lifetime `'a` defined here
2336
LL | t
2437
| ^ returning this value requires that `'a` must outlive `'static`
2538

2639
error[E0521]: borrowed data escapes outside of function
27-
--> $DIR/regions-static-bound.rs:15:5
40+
--> $DIR/regions-static-bound.rs:17:5
2841
|
2942
LL | fn error(u: &(), v: &()) {
3043
| - - let's call the lifetime of this reference `'1`
@@ -37,7 +50,7 @@ LL | static_id(&u);
3750
| argument requires that `'1` must outlive `'static`
3851

3952
error[E0521]: borrowed data escapes outside of function
40-
--> $DIR/regions-static-bound.rs:17:5
53+
--> $DIR/regions-static-bound.rs:19:5
4154
|
4255
LL | fn error(u: &(), v: &()) {
4356
| - - let's call the lifetime of this reference `'2`
@@ -50,6 +63,6 @@ LL | static_id_indirect(&v);
5063
| `v` escapes the function body here
5164
| argument requires that `'2` must outlive `'static`
5265

53-
error: aborting due to 3 previous errors; 2 warnings emitted
66+
error: aborting due to 3 previous errors; 3 warnings emitted
5467

5568
For more information about this error, try `rustc --explain E0521`.

0 commit comments

Comments
 (0)