Lint elided lifetimes in path on the AST.

This commit is contained in:
Camille GILLOT 2022-03-10 23:12:35 +01:00
parent ca57bada05
commit a9e13fa553
24 changed files with 279 additions and 154 deletions

View file

@ -2,9 +2,13 @@ error[E0726]: implicit elided lifetime not allowed here
--> $DIR/async-fn-path-elision.rs:5:20
|
LL | async fn error(lt: HasLifetime) {
| ^^^^^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
| ^^^^^^^^^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
LL | async fn error(lt: HasLifetime<'_>) {
| ++++
error: aborting due to previous error

View file

@ -2,9 +2,13 @@ error[E0726]: implicit elided lifetime not allowed here
--> $DIR/path-elided.rs:7:18
|
LL | impl MyTrait for Foo {
| ^^^- help: indicate the anonymous lifetime: `<'_>`
| ^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
LL | impl MyTrait for Foo<'_> {
| ++++
error: aborting due to previous error

View file

@ -2,9 +2,13 @@ error[E0726]: implicit elided lifetime not allowed here
--> $DIR/trait-elided.rs:5:6
|
LL | impl MyTrait for u32 {}
| ^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
| ^^^^^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
LL | impl MyTrait<'_> for u32 {}
| ++++
error: aborting due to previous error

View file

@ -44,9 +44,13 @@ error[E0726]: implicit elided lifetime not allowed here
--> $DIR/issue-10412.rs:7:13
|
LL | impl<'self> Serializable<str> for &'self str {
| ^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Serializable<'_, str>`
| ^^^^^^^^^^^^^^^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
LL | impl<'self> Serializable<'_, str> for &'self str {
| +++
error[E0277]: the size for values of type `str` cannot be known at compilation time
--> $DIR/issue-10412.rs:7:13

View file

@ -2,13 +2,17 @@ error: hidden lifetime parameters in types are deprecated
--> $DIR/issue-91763.rs:8:20
|
LL | fn f() -> Ptr<Thing>;
| ^ expected named lifetime parameter
| ^ expected lifetime parameter
|
note: the lint level is defined here
--> $DIR/issue-91763.rs:3:9
|
LL | #![deny(elided_lifetimes_in_paths)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
help: indicate the anonymous lifetime
|
LL | fn f() -> Ptr<Thing><'_>;
| ++++
error: aborting due to previous error

View file

@ -2,13 +2,13 @@ warning: hidden lifetime parameters in types are deprecated
--> $DIR/allowed-by-default-lint.rs:9:12
|
LL | fn foo(x: &Foo) {}
| ^^^ expected named lifetime parameter
| ^^^ expected lifetime parameter
|
= note: requested on the command line with `--force-warn elided-lifetimes-in-paths`
help: consider using the `'_` lifetime
help: indicate the anonymous lifetime
|
LL | fn foo(x: &Foo<'_>) {}
| ~~~~~~~
| ++++
warning: 1 warning emitted

View file

@ -19,9 +19,9 @@ pub struct CheaterDetectionMechanism {}
impl fmt::Debug for CheaterDetectionMechanism {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
//~^ WARN hidden lifetime parameters in types are deprecated
//~| NOTE expected named lifetime parameter
//~| NOTE expected lifetime parameter
//~| NOTE explicit anonymous lifetimes aid
//~| HELP consider using the `'_` lifetime
//~| HELP indicate the anonymous lifetime
fmt.debug_struct("CheaterDetectionMechanism").finish()
}
}

View file

@ -2,7 +2,9 @@ warning: hidden lifetime parameters in types are deprecated
--> $DIR/reasons.rs:20:34
|
LL | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
| ^^^^^^^^^ expected named lifetime parameter
| -----^^^^^^^^^
| |
| expected lifetime parameter
|
= note: explicit anonymous lifetimes aid reasoning about ownership
note: the lint level is defined here
@ -10,10 +12,10 @@ note: the lint level is defined here
|
LL | #![warn(elided_lifetimes_in_paths,
| ^^^^^^^^^^^^^^^^^^^^^^^^^
help: consider using the `'_` lifetime
help: indicate the anonymous lifetime
|
LL | fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
| ~~~~~~~~~~~~~
| ++++
warning: variable `Social_exchange_psychology` should have a snake case name
--> $DIR/reasons.rs:30:9

View file

@ -2,9 +2,13 @@ error[E0726]: implicit elided lifetime not allowed here
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:13:16
|
LL | impl Trait for Ref {}
| ^^^- help: indicate the anonymous lifetime: `<'_>`
| ^^^ expected lifetime parameter
|
= note: assuming a `'static` lifetime...
help: indicate the anonymous lifetime
|
LL | impl Trait for Ref<'_> {}
| ++++
error: incompatible lifetime on type
--> $DIR/wf-in-foreign-fn-decls-issue-80468.rs:16:21