about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPavel Grigorenko <GrigorenkoPV@ya.ru>2024-09-01 16:49:55 +0300
committerPavel Grigorenko <GrigorenkoPV@ya.ru>2024-09-06 17:06:35 +0300
commit9e2d264fa251f98780084382a071e10a123770d6 (patch)
tree226df15d4fe43dc9900558fd115002e9fc07233d
parent547db4a4b7c9bfea52b519d0095510126a0a1cb0 (diff)
downloadrust-9e2d264fa251f98780084382a071e10a123770d6.tar.gz
rust-9e2d264fa251f98780084382a071e10a123770d6.zip
Hack around a conflict with `clippy::needless_lifetimes`
-rw-r--r--compiler/rustc_lint/src/lints.rs7
-rw-r--r--tests/ui/async-await/issues/issue-63388-1.stderr4
-rw-r--r--tests/ui/const-generics/type-dependent/issue-71348.full.stderr4
-rw-r--r--tests/ui/const-generics/type-dependent/issue-71348.min.stderr4
-rw-r--r--tests/ui/consts/min_const_fn/min_const_fn.stderr9
-rw-r--r--tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr4
-rw-r--r--tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr4
-rw-r--r--tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr4
-rw-r--r--tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr4
-rw-r--r--tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr4
-rw-r--r--tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr19
-rw-r--r--tests/ui/object-lifetime/object-lifetime-default-elision.stderr4
-rw-r--r--tests/ui/self/elision/ignore-non-reference-lifetimes.stderr9
-rw-r--r--tests/ui/self/self_lifetime-async.stderr9
-rw-r--r--tests/ui/self/self_lifetime.stderr9
-rw-r--r--tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr4
-rw-r--r--tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr4
-rw-r--r--tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr4
18 files changed, 7 insertions, 103 deletions
diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs
index 693f1b22587..ae7e9659856 100644
--- a/compiler/rustc_lint/src/lints.rs
+++ b/compiler/rustc_lint/src/lints.rs
@@ -2639,6 +2639,13 @@ impl<G: EmissionGuarantee> LintDiagnostic<'_, G> for ElidedNamedLifetime {
         if let Some(declaration) = declaration {
             diag.span_label(declaration, fluent::lint_label_named);
         }
+        // FIXME(GrigorenkoPV): this `if` and `return` should be removed,
+        //  but currently this lint's suggestions can conflict with those of `clippy::needless_lifetimes`:
+        //  https://github.com/rust-lang/rust/pull/129840#issuecomment-2323349119
+        // HACK: `'static` suggestions will never sonflict, emit only those for now.
+        if name != rustc_span::symbol::kw::StaticLifetime {
+            return;
+        }
         match kind {
             MissingLifetimeKind::Underscore => diag.span_suggestion_verbose(
                 span,
diff --git a/tests/ui/async-await/issues/issue-63388-1.stderr b/tests/ui/async-await/issues/issue-63388-1.stderr
index 713e4e4dcf5..ef74bfe3237 100644
--- a/tests/ui/async-await/issues/issue-63388-1.stderr
+++ b/tests/ui/async-await/issues/issue-63388-1.stderr
@@ -8,10 +8,6 @@ LL |     ) -> &dyn Foo
    |          ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     ) -> &'a dyn Foo
-   |           ++
 
 error[E0621]: explicit lifetime required in the type of `foo`
   --> $DIR/issue-63388-1.rs:13:5
diff --git a/tests/ui/const-generics/type-dependent/issue-71348.full.stderr b/tests/ui/const-generics/type-dependent/issue-71348.full.stderr
index 394259ce55d..177ff20fbf9 100644
--- a/tests/ui/const-generics/type-dependent/issue-71348.full.stderr
+++ b/tests/ui/const-generics/type-dependent/issue-71348.full.stderr
@@ -5,10 +5,6 @@ LL |     fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Ta
    |            -- lifetime `'a` declared here                          ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<'a, N>>::Target
-   |                                                                     +++
 
 warning: 1 warning emitted
 
diff --git a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr
index 0f0d75dbac1..5aee282952a 100644
--- a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr
+++ b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr
@@ -5,10 +5,6 @@ LL |     fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Ta
    |            -- lifetime `'a` declared here                          ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<'a, N>>::Target
-   |                                                                     +++
 
 error: `&'static str` is forbidden as the type of a const generic parameter
   --> $DIR/issue-71348.rs:10:24
diff --git a/tests/ui/consts/min_const_fn/min_const_fn.stderr b/tests/ui/consts/min_const_fn/min_const_fn.stderr
index 1e88a908af0..4b348a182b8 100644
--- a/tests/ui/consts/min_const_fn/min_const_fn.stderr
+++ b/tests/ui/consts/min_const_fn/min_const_fn.stderr
@@ -8,10 +8,6 @@ LL |     const fn get_lt(&'a self) -> &T { &self.0 }
    |                                  ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     const fn get_lt(&'a self) -> &'a T { &self.0 }
-   |                                   ++
 
 warning: elided lifetime has a name
   --> $DIR/min_const_fn.rs:48:42
@@ -21,11 +17,6 @@ LL | impl<'a, T> Foo<T> {
 ...
 LL |     const fn get_mut_lt(&'a mut self) -> &mut T { &mut self.0 }
    |                                          ^ this elided lifetime gets resolved as `'a`
-   |
-help: consider specifying it explicitly
-   |
-LL |     const fn get_mut_lt(&'a mut self) -> &'a mut T { &mut self.0 }
-   |                                           ++
 
 error[E0493]: destructor of `Foo<T>` cannot be evaluated at compile-time
   --> $DIR/min_const_fn.rs:37:25
diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
index ccea9d5e6e9..d0f8f7689d1 100644
--- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
+++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
@@ -17,10 +17,6 @@ LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
    |                    -- lifetime `'a` declared here  ^^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
-   |                                                    ~~
 
 error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
   --> $DIR/impl-fn-hrtb-bounds.rs:4:41
diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr
index a60f3986843..50a9f3ebeab 100644
--- a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr
+++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr
@@ -5,10 +5,6 @@ LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
    |      -- lifetime `'a` declared here            ^^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + 'a) {
-   |                                                ~~
 
 error[E0792]: expected generic lifetime parameter, found `'_`
   --> $DIR/impl-fn-predefined-lifetimes.rs:7:9
diff --git a/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr b/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr
index 6eea25b4fc8..bff3ffd934a 100644
--- a/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr
+++ b/tests/ui/impl-trait/rpit-assoc-pair-with-lifetime.stderr
@@ -5,10 +5,6 @@ LL | pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item =
    |             -- lifetime `'a` declared here                                       ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | pub fn iter<'a>(v: Vec<(u32, &'a u32)>) -> impl DoubleEndedIterator<Item = (u32, &'a u32)> {
-   |                                                                                   ++
 
 warning: 1 warning emitted
 
diff --git a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr
index 1339c644f53..f835d2655bb 100644
--- a/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr
+++ b/tests/ui/lifetimes/lifetime-elision-return-type-requires-explicit-lifetime.stderr
@@ -114,10 +114,6 @@ LL | fn m<'a>(_: &'a Foo<'a>) -> &str { "" }
    |      lifetime `'a` declared here
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn m<'a>(_: &'a Foo<'a>) -> &'a str { "" }
-   |                              ++
 
 error: aborting due to 7 previous errors; 1 warning emitted
 
diff --git a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
index 144f9454513..2d5d4fb0e72 100644
--- a/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
+++ b/tests/ui/lifetimes/lifetime-errors/ex1-return-one-existing-name-if-else-using-impl-3.stderr
@@ -7,10 +7,6 @@ LL |   fn foo<'a>(&'a self, x: &i32) -> &i32 {
    |          lifetime `'a` declared here
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |   fn foo<'a>(&'a self, x: &i32) -> &'a i32 {
-   |                                     ++
 
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:9:36
diff --git a/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr b/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr
index 834292d103d..249ae146b16 100644
--- a/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr
+++ b/tests/ui/lint/elided-named-lifetimes/missing-lifetime-kind.stderr
@@ -11,10 +11,6 @@ note: the lint level is defined here
    |
 LL | #![deny(elided_named_lifetimes)]
    |         ^^^^^^^^^^^^^^^^^^^^^^
-help: consider specifying it explicitly
-   |
-LL | fn ampersand<'a>(x: &'a u8) -> &'a u8 {
-   |                                 ++
 
 error: elided lifetime has a name
   --> $DIR/missing-lifetime-kind.rs:10:31
@@ -23,11 +19,6 @@ LL | fn brackets<'a>(x: &'a u8) -> Brackets {
    |             --                ^^^^^^^^ this elided lifetime gets resolved as `'a`
    |             |
    |             lifetime `'a` declared here
-   |
-help: consider specifying it explicitly
-   |
-LL | fn brackets<'a>(x: &'a u8) -> Brackets<'a> {
-   |                                       ++++
 
 error: elided lifetime has a name
   --> $DIR/missing-lifetime-kind.rs:17:33
@@ -36,11 +27,6 @@ LL | fn comma<'a>(x: &'a u8) -> Comma<u8> {
    |          --                     ^ this elided lifetime gets resolved as `'a`
    |          |
    |          lifetime `'a` declared here
-   |
-help: consider specifying it explicitly
-   |
-LL | fn comma<'a>(x: &'a u8) -> Comma<'a, u8> {
-   |                                  +++
 
 error: elided lifetime has a name
   --> $DIR/missing-lifetime-kind.rs:22:34
@@ -49,11 +35,6 @@ LL | fn underscore<'a>(x: &'a u8) -> &'_ u8 {
    |               --                 ^^ this elided lifetime gets resolved as `'a`
    |               |
    |               lifetime `'a` declared here
-   |
-help: consider specifying it explicitly
-   |
-LL | fn underscore<'a>(x: &'a u8) -> &'a u8 {
-   |                                  ~~
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/object-lifetime/object-lifetime-default-elision.stderr b/tests/ui/object-lifetime/object-lifetime-default-elision.stderr
index f8ed92111a9..b44a184c684 100644
--- a/tests/ui/object-lifetime/object-lifetime-default-elision.stderr
+++ b/tests/ui/object-lifetime/object-lifetime-default-elision.stderr
@@ -7,10 +7,6 @@ LL | fn load2<'a>(ss: &'a dyn SomeTrait) -> &dyn SomeTrait {
    |          lifetime `'a` declared here
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn load2<'a>(ss: &'a dyn SomeTrait) -> &'a dyn SomeTrait {
-   |                                         ++
 
 error: lifetime may not live long enough
   --> $DIR/object-lifetime-default-elision.rs:73:5
diff --git a/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr b/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr
index 13cc3a431a5..4465dbae529 100644
--- a/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr
+++ b/tests/ui/self/elision/ignore-non-reference-lifetimes.stderr
@@ -5,21 +5,12 @@ LL |     fn a<'a>(self: Self, a: &'a str) -> &str {
    |          -- lifetime `'a` declared here ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     fn a<'a>(self: Self, a: &'a str) -> &'a str {
-   |                                          ++
 
 warning: elided lifetime has a name
   --> $DIR/ignore-non-reference-lifetimes.rs:10:44
    |
 LL |     fn b<'a>(self: Foo<'b>, a: &'a str) -> &str {
    |          -- lifetime `'a` declared here    ^ this elided lifetime gets resolved as `'a`
-   |
-help: consider specifying it explicitly
-   |
-LL |     fn b<'a>(self: Foo<'b>, a: &'a str) -> &'a str {
-   |                                             ++
 
 warning: 2 warnings emitted
 
diff --git a/tests/ui/self/self_lifetime-async.stderr b/tests/ui/self/self_lifetime-async.stderr
index 2892d790ac7..32de3fd18c9 100644
--- a/tests/ui/self/self_lifetime-async.stderr
+++ b/tests/ui/self/self_lifetime-async.stderr
@@ -7,21 +7,12 @@ LL |     async fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
    |                  lifetime `'b` declared here
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     async fn foo<'b>(self: &'b Foo<'a>) -> &'b () { self.0 }
-   |                                             ++
 
 warning: elided lifetime has a name
   --> $DIR/self_lifetime-async.rs:12:52
    |
 LL |     async fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
    |                  -- lifetime `'a` declared here    ^ this elided lifetime gets resolved as `'a`
-   |
-help: consider specifying it explicitly
-   |
-LL |     async fn bar<'a>(self: &Alias, arg: &'a ()) -> &'a () { arg }
-   |                                                     ++
 
 warning: 2 warnings emitted
 
diff --git a/tests/ui/self/self_lifetime.stderr b/tests/ui/self/self_lifetime.stderr
index ceb0ce345a3..cd8f4d8adf8 100644
--- a/tests/ui/self/self_lifetime.stderr
+++ b/tests/ui/self/self_lifetime.stderr
@@ -7,21 +7,12 @@ LL |     fn foo<'b>(self: &'b Foo<'a>) -> &() { self.0 }
    |            lifetime `'b` declared here
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL |     fn foo<'b>(self: &'b Foo<'a>) -> &'b () { self.0 }
-   |                                       ++
 
 warning: elided lifetime has a name
   --> $DIR/self_lifetime.rs:13:46
    |
 LL |     fn bar<'a>(self: &Alias, arg: &'a ()) -> &() { arg }
    |            -- lifetime `'a` declared here    ^ this elided lifetime gets resolved as `'a`
-   |
-help: consider specifying it explicitly
-   |
-LL |     fn bar<'a>(self: &Alias, arg: &'a ()) -> &'a () { arg }
-   |                                               ++
 
 warning: 2 warnings emitted
 
diff --git a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
index 3744dd9f996..30f4509d49d 100644
--- a/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
+++ b/tests/ui/suggestions/impl-trait-missing-lifetime-gated.stderr
@@ -131,10 +131,6 @@ LL | fn resolved_anonymous<'a, T: 'a>(f: impl Fn(&'a str) -> &T) {
    |                       -- lifetime `'a` declared here    ^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn resolved_anonymous<'a, T: 'a>(f: impl Fn(&'a str) -> &'a T) {
-   |                                                          ++
 
 error[E0658]: anonymous lifetimes in `impl Trait` are unstable
   --> $DIR/impl-trait-missing-lifetime-gated.rs:6:35
diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
index baa5fa949ec..ea01dcd5020 100644
--- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
+++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr
@@ -13,10 +13,6 @@ LL | fn ok2<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + '_ + 'a
    |        -- lifetime `'a` declared here                          ^^ this elided lifetime gets resolved as `'a`
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn ok2<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() + 'a + 'a
-   |                                                                ~~
 
 error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not appear in bounds
   --> $DIR/missing-lifetimes-in-signature.rs:19:5
diff --git a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
index 376e58ef9e0..e2c21f1636b 100644
--- a/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
+++ b/tests/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
@@ -7,10 +7,6 @@ LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
    |             lifetime `'a` declared here
    |
    = note: `#[warn(elided_named_lifetimes)]` on by default
-help: consider specifying it explicitly
-   |
-LL | fn defining<'a, T>(x: &'a i32) -> Opaque<'a, T> { x }
-   |                                          +++
 
 error[E0700]: hidden type for `Opaque2<T>` captures lifetime that does not appear in bounds
   --> $DIR/missing_lifetime_bound.rs:5:47