Skip to content

Commit f337a79

Browse files
committed
update tests
Signed-off-by: Zhi Qi <[email protected]>
1 parent c40ec11 commit f337a79

16 files changed

+56
-99
lines changed

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

-1
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

-11
This file was deleted.

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

-1
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

+2-11
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

+2
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

+6-3
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

+2
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

+8-5
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

+5-3
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

+22-9
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`.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fn f<'a: 'static>(_: &'a i32) {} //~WARN unnecessary lifetime parameter `'a`
1+
fn f<'a: 'static>(_: &'a i32) {}
22

33
fn main() {
44
let x = 0;
+1-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
warning: unnecessary lifetime parameter `'a`
2-
--> $DIR/static-lifetime-bound.rs:1:6
3-
|
4-
LL | fn f<'a: 'static>(_: &'a i32) {}
5-
| ^^
6-
|
7-
= note: `#[warn(named_static_lifetimes)]` on by default
8-
= help: you can use the `'static` lifetime directly, in place of `'a`
9-
101
error[E0597]: `x` does not live long enough
112
--> $DIR/static-lifetime-bound.rs:5:7
123
|
@@ -20,6 +11,6 @@ LL | f(&x);
2011
LL | }
2112
| - `x` dropped here while still borrowed
2213

23-
error: aborting due to previous error; 1 warning emitted
14+
error: aborting due to previous error
2415

2516
For more information about this error, try `rustc --explain E0597`.

tests/ui/type-alias-impl-trait/bounds-are-checked.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
type X<'a> = impl Into<&'static str> + From<&'a str>;
77

88
fn f<'a: 'static>(t: &'a str) -> X<'a> {
9-
//~^ WARNING unnecessary lifetime parameter
109
t
1110
//~^ ERROR expected generic lifetime parameter, found `'static`
1211
}
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
warning: unnecessary lifetime parameter `'a`
2-
--> $DIR/bounds-are-checked.rs:8:6
3-
|
4-
LL | fn f<'a: 'static>(t: &'a str) -> X<'a> {
5-
| ^^
6-
|
7-
= note: `#[warn(named_static_lifetimes)]` on by default
8-
= help: you can use the `'static` lifetime directly, in place of `'a`
9-
101
error[E0792]: expected generic lifetime parameter, found `'static`
11-
--> $DIR/bounds-are-checked.rs:10:5
2+
--> $DIR/bounds-are-checked.rs:9:5
123
|
134
LL | type X<'a> = impl Into<&'static str> + From<&'a str>;
145
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
156
...
167
LL | t
178
| ^
189

19-
error: aborting due to previous error; 1 warning emitted
10+
error: aborting due to previous error
2011

2112
For more information about this error, try `rustc --explain E0792`.

tests/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ mod test_lifetime_param {
44
type Ty<'a> = impl Sized + 'a;
55
fn defining(a: &str) -> Ty<'_> { a }
66
fn assert_static<'a: 'static>() {}
7-
//~^ WARN: unnecessary lifetime parameter `'a`
87
fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
98
//~^ ERROR: lifetime may not live long enough
109
}
@@ -13,14 +12,12 @@ mod test_higher_kinded_lifetime_param {
1312
type Ty<'a> = impl Sized + 'a;
1413
fn defining(a: &str) -> Ty<'_> { a }
1514
fn assert_static<'a: 'static>() {}
16-
//~^ WARN: unnecessary lifetime parameter `'a`
1715
fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
1816
//~^ ERROR: lifetime may not live long enough
1917
}
2018

2119
mod test_higher_kinded_lifetime_param2 {
2220
fn assert_static<'a: 'static>() {}
23-
//~^ WARN: unnecessary lifetime parameter `'a`
2421
fn test<'a>() { assert_static::<'a>() }
2522
//~^ ERROR: lifetime may not live long enough
2623
}
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,25 @@
1-
warning: unnecessary lifetime parameter `'a`
2-
--> $DIR/implied_lifetime_wf_check3.rs:6:22
3-
|
4-
LL | fn assert_static<'a: 'static>() {}
5-
| ^^
6-
|
7-
= help: you can use the `'static` lifetime directly, in place of `'a`
8-
9-
warning: unnecessary lifetime parameter `'a`
10-
--> $DIR/implied_lifetime_wf_check3.rs:15:22
11-
|
12-
LL | fn assert_static<'a: 'static>() {}
13-
| ^^
14-
|
15-
= help: you can use the `'static` lifetime directly, in place of `'a`
16-
17-
warning: unnecessary lifetime parameter `'a`
18-
--> $DIR/implied_lifetime_wf_check3.rs:22:22
19-
|
20-
LL | fn assert_static<'a: 'static>() {}
21-
| ^^
22-
|
23-
= help: you can use the `'static` lifetime directly, in place of `'a`
24-
251
error: lifetime may not live long enough
26-
--> $DIR/implied_lifetime_wf_check3.rs:8:43
2+
--> $DIR/implied_lifetime_wf_check3.rs:7:43
273
|
284
LL | fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
295
| -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
306

317
error: lifetime may not live long enough
32-
--> $DIR/implied_lifetime_wf_check3.rs:17:46
8+
--> $DIR/implied_lifetime_wf_check3.rs:15:46
339
|
3410
LL | fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
3511
| -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
3612

3713
error: lifetime may not live long enough
38-
--> $DIR/implied_lifetime_wf_check3.rs:24:21
14+
--> $DIR/implied_lifetime_wf_check3.rs:21:21
3915
|
4016
LL | fn test<'a>() { assert_static::<'a>() }
4117
| -- ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
4218
| |
4319
| lifetime `'a` defined here
4420

4521
error[E0310]: the parameter type `A` may not live long enough
46-
--> $DIR/implied_lifetime_wf_check3.rs:32:41
22+
--> $DIR/implied_lifetime_wf_check3.rs:29:41
4723
|
4824
LL | fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
4925
| ^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
@@ -53,6 +29,6 @@ help: consider adding an explicit lifetime bound...
5329
LL | fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() }
5430
| +++++++++
5531

56-
error: aborting due to 4 previous errors; 3 warnings emitted
32+
error: aborting due to 4 previous errors
5733

5834
For more information about this error, try `rustc --explain E0310`.

0 commit comments

Comments
 (0)