about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-12-16 01:58:26 +0000
committerMichael Goulet <michael@errs.io>2024-04-09 12:17:34 -0400
commita9e262a32dbef558bbe40731ddfe272cb2f11948 (patch)
tree7b00dc45782530088aa2204d02ae31050fd6130a /compiler
parentee78eab62be926b69236c9a344fbcec2b3355bbd (diff)
downloadrust-a9e262a32dbef558bbe40731ddfe272cb2f11948.tar.gz
rust-a9e262a32dbef558bbe40731ddfe272cb2f11948.zip
Split back out unused_lifetimes -> redundant_lifetimes
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_analysis/src/check/wfcheck.rs4
-rw-r--r--compiler/rustc_lint_defs/src/builtin.rs26
2 files changed, 26 insertions, 4 deletions
diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
index 01f87ecdebb..cc54db18750 100644
--- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs
+++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs
@@ -2118,8 +2118,8 @@ fn lint_redundant_lifetimes<'tcx>(
                 && outlives_env.free_region_map().sub_free_regions(tcx, victim, candidate)
             {
                 shadowed.insert(victim);
-                tcx.emit_spanned_lint(
-                    rustc_lint_defs::builtin::UNUSED_LIFETIMES,
+                tcx.emit_node_span_lint(
+                    rustc_lint_defs::builtin::REDUNDANT_LIFETIMES,
                     tcx.local_def_id_to_hir_id(def_id.expect_local()),
                     tcx.def_span(def_id),
                     RedundantLifetimeArgsLint { candidate, victim },
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs
index c2df3e1015f..2713690f812 100644
--- a/compiler/rustc_lint_defs/src/builtin.rs
+++ b/compiler/rustc_lint_defs/src/builtin.rs
@@ -79,6 +79,7 @@ declare_lint_pass! {
         PROC_MACRO_BACK_COMPAT,
         PROC_MACRO_DERIVE_RESOLUTION_FALLBACK,
         PUB_USE_OF_PRIVATE_EXTERN_CRATE,
+        REDUNDANT_LIFETIMES,
         REFINING_IMPL_TRAIT_INTERNAL,
         REFINING_IMPL_TRAIT_REACHABLE,
         RENAMED_AND_REMOVED_LINTS,
@@ -1694,6 +1695,27 @@ declare_lint! {
     /// #[deny(unused_lifetimes)]
     ///
     /// pub fn foo<'a>() {}
+    /// ```
+    ///
+    /// {{produces}}
+    ///
+    /// ### Explanation
+    ///
+    /// Unused lifetime parameters may signal a mistake or unfinished code.
+    /// Consider removing the parameter.
+    pub UNUSED_LIFETIMES,
+    Allow,
+    "detects lifetime parameters that are never used"
+}
+
+declare_lint! {
+    /// The `redundant_lifetimes` lint detects lifetime parameters that are
+    /// redundant because they are equal to another named lifetime.
+    ///
+    /// ### Example
+    ///
+    /// ```rust,compile_fail
+    /// #[deny(redundant_lifetimes)]
     ///
     /// // `'a = 'static`, so all usages of `'a` can be replaced with `'static`
     /// pub fn bar<'a: 'static>() {}
@@ -1708,9 +1730,9 @@ declare_lint! {
     ///
     /// Unused lifetime parameters may signal a mistake or unfinished code.
     /// Consider removing the parameter.
-    pub UNUSED_LIFETIMES,
+    pub REDUNDANT_LIFETIMES,
     Allow,
-    "detects lifetime parameters that are never used"
+    "detects lifetime parameters that are redundant because they are equal to some other named lifetime"
 }
 
 declare_lint! {