Skip to content

Commit 0be2da3

Browse files
committed
use "UNUSED_LIFETIMES" instead
Signed-off-by: Zhi Qi <[email protected]>
1 parent f043106 commit 0be2da3

File tree

2 files changed

+2
-37
lines changed

2 files changed

+2
-37
lines changed

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
969969
}
970970
this.insert_lifetime(lt, ResolvedArg::StaticLifetime);
971971
this.tcx.struct_span_lint_hir(
972-
lint::builtin::NAMED_STATIC_LIFETIMES,
972+
lint::builtin::UNUSED_LIFETIMES,
973973
lifetime.hir_id,
974974
lifetime.ident.span,
975975
format!(
@@ -981,7 +981,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
981981
"you can use the `'static` lifetime directly, in place of `{}`",
982982
lifetime.ident,
983983
);
984-
lint.note(help)
984+
lint.help(help)
985985
},
986986
);
987987
}

compiler/rustc_lint_defs/src/builtin.rs

-35
Original file line numberDiff line numberDiff line change
@@ -1618,40 +1618,6 @@ declare_lint! {
16181618
"detects lifetime parameters that are never used"
16191619
}
16201620

1621-
declare_lint! {
1622-
/// The `named_static_lifetimes` lint detects lifetime parameters that are
1623-
/// defined as outliving the static lifetime.
1624-
///
1625-
/// ### Example
1626-
///
1627-
/// ```rust,compile_fail
1628-
/// #[deny(named_static_lifetimes)]
1629-
///
1630-
/// pub fn foo<'a>(_s: &'a str) where 'a: 'static {}
1631-
/// ```
1632-
///
1633-
/// {{produces}}
1634-
///
1635-
/// ### Explanation
1636-
///
1637-
/// By definition, the static lifetime (`'static`) outlives every other
1638-
/// lifetime. If another lifetime `'a` lives at least as long as `'static`,
1639-
/// then it is identical to `'static`. In that case, there is no need for
1640-
/// the name `'a`, and it likely only makes the code harder to read.
1641-
///
1642-
/// To fix this, consider using `'static` instead of the named lifetime.
1643-
/// Here is the result of doing that in the example above:
1644-
///
1645-
/// ```rust
1646-
/// #[deny(named_static_lifetimes)]
1647-
///
1648-
/// pub fn foo(_s: &'static str) {}
1649-
/// ```
1650-
pub NAMED_STATIC_LIFETIMES,
1651-
Warn,
1652-
"detects lifetime parameters that are identical to `'static`"
1653-
}
1654-
16551621
declare_lint! {
16561622
/// The `tyvar_behind_raw_pointer` lint detects raw pointer to an
16571623
/// inference variable.
@@ -3309,7 +3275,6 @@ declare_lint_pass! {
33093275
UNCONDITIONAL_RECURSION,
33103276
SINGLE_USE_LIFETIMES,
33113277
UNUSED_LIFETIMES,
3312-
NAMED_STATIC_LIFETIMES,
33133278
UNUSED_LABELS,
33143279
TYVAR_BEHIND_RAW_POINTER,
33153280
ELIDED_LIFETIMES_IN_PATHS,

0 commit comments

Comments
 (0)