rust/tests/ui/regions/regions-static-bound.stderr
Zhi Qi ce2ae62d68 Convert a hard-warning about named static lifetimes into lint "unused_lifetimes"
Define the `named_static_lifetimes` lint

This lint will replace the existing hard-warning.

Replace the named static lifetime hard-warning with the new lint

Update the UI tests for the `named_static_lifetimes` lint

Remove the direct dependency on `rustc_lint_defs`

fix build

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

use "UNUSED_LIFETIMES" instead

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

update 1 test and fix typo

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

update tests

Signed-off-by: Zhi Qi <qizhi@pingcap.com>

fix tests: add extra blank line

Signed-off-by: Zhi Qi <qizhi@pingcap.com>
2023-02-22 09:44:26 +08:00

69 lines
2.3 KiB
Plaintext

warning: lifetime parameter `'b` never used
--> $DIR/regions-static-bound.rs:3:17
|
LL | fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
| -^^
| |
| help: elide the unused lifetime
|
note: the lint level is defined here
--> $DIR/regions-static-bound.rs:1:9
|
LL | #![warn(unused_lifetimes)]
| ^^^^^^^^^^^^^^^^
warning: unnecessary lifetime parameter `'a`
--> $DIR/regions-static-bound.rs:3:53
|
LL | fn static_id<'a,'b>(t: &'a ()) -> &'static () where 'a: 'static { t }
| ^^
|
= help: you can use the `'static` lifetime directly, in place of `'a`
warning: unnecessary lifetime parameter `'b`
--> $DIR/regions-static-bound.rs:8:19
|
LL | where 'a: 'b, 'b: 'static { t }
| ^^
|
= help: you can use the `'static` lifetime directly, in place of `'b`
error: lifetime may not live long enough
--> $DIR/regions-static-bound.rs:12:5
|
LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
| -- lifetime `'a` defined here
LL | t
| ^ returning this value requires that `'a` must outlive `'static`
error[E0521]: borrowed data escapes outside of function
--> $DIR/regions-static-bound.rs:17:5
|
LL | fn error(u: &(), v: &()) {
| - - let's call the lifetime of this reference `'1`
| |
| `u` is a reference that is only valid in the function body
LL | static_id(&u);
| ^^^^^^^^^^^^^
| |
| `u` escapes the function body here
| argument requires that `'1` must outlive `'static`
error[E0521]: borrowed data escapes outside of function
--> $DIR/regions-static-bound.rs:19:5
|
LL | fn error(u: &(), v: &()) {
| - - let's call the lifetime of this reference `'2`
| |
| `v` is a reference that is only valid in the function body
...
LL | static_id_indirect(&v);
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| `v` escapes the function body here
| argument requires that `'2` must outlive `'static`
error: aborting due to 3 previous errors; 3 warnings emitted
For more information about this error, try `rustc --explain E0521`.