diff options
| author | Michael Goulet <michael@errs.io> | 2023-11-27 21:54:03 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-04-09 12:15:27 -0400 |
| commit | 89409494e3cf0ece89116b4838de609e07290ff1 (patch) | |
| tree | c3a8a8bccc63d7c09bacaa892d25faa44a0ad18c /compiler | |
| parent | 03c901fd35b67ee0e67c13c350bc4e1a60e1d91d (diff) | |
| download | rust-89409494e3cf0ece89116b4838de609e07290ff1.tar.gz rust-89409494e3cf0ece89116b4838de609e07290ff1.zip | |
Actually, just reuse the UNUSED_LIFETIMES lint
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_lint/messages.ftl | 3 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/redundant_lifetime_args.rs | 17 |
3 files changed, 8 insertions, 38 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 0b8ac9926e4..affd678fc6c 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -20,7 +20,6 @@ use rustc_middle::hir::nested_filter; use rustc_middle::middle::resolve_bound_vars::*; use rustc_middle::query::Providers; use rustc_middle::ty::{self, TyCtxt, TypeSuperVisitable, TypeVisitor}; -use rustc_session::lint; use rustc_span::def_id::DefId; use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; @@ -867,31 +866,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { }) => { self.visit_lifetime(lifetime); walk_list!(self, visit_param_bound, bounds); - - if lifetime.res != hir::LifetimeName::Static { - for bound in bounds { - let hir::GenericBound::Outlives(lt) = bound else { - continue; - }; - if lt.res != hir::LifetimeName::Static { - continue; - } - self.insert_lifetime(lt, ResolvedArg::StaticLifetime); - self.tcx.node_span_lint( - lint::builtin::UNUSED_LIFETIMES, - lifetime.hir_id, - lifetime.ident.span, - format!("unnecessary lifetime parameter `{}`", lifetime.ident), - |lint| { - let help = format!( - "you can use the `'static` lifetime directly, in place of `{}`", - lifetime.ident, - ); - lint.help(help); - }, - ); - } - } } &hir::WherePredicate::EqPredicate(hir::WhereEqPredicate { lhs_ty, rhs_ty, .. }) => { self.visit_ty(lhs_ty); diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl index ad0a5a2b624..cc7a87544bc 100644 --- a/compiler/rustc_lint/messages.ftl +++ b/compiler/rustc_lint/messages.ftl @@ -534,7 +534,8 @@ lint_reason_must_be_string_literal = reason must be a string literal lint_reason_must_come_last = reason in lint attribute must come last -lint_redundant_lifetime_args = lifetime `{$victim}` is required to be equal to `{$candidate}`, and is redundant and can be removed +lint_redundant_lifetime_args = unnecessary lifetime parameter `{$victim}` + .note = you can use the `{$candidate}` lifetime directly, in place of `{$victim}` lint_redundant_semicolons = unnecessary trailing {$multiple -> diff --git a/compiler/rustc_lint/src/redundant_lifetime_args.rs b/compiler/rustc_lint/src/redundant_lifetime_args.rs index 7a7c5387369..59d2edba124 100644 --- a/compiler/rustc_lint/src/redundant_lifetime_args.rs +++ b/compiler/rustc_lint/src/redundant_lifetime_args.rs @@ -8,19 +8,13 @@ use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::{SubregionOrigin, TyCtxtInferExt}; use rustc_macros::LintDiagnostic; use rustc_middle::ty::{self, TyCtxt}; +use rustc_session::lint::builtin::UNUSED_LIFETIMES; use rustc_span::DUMMY_SP; use rustc_trait_selection::traits::{outlives_bounds::InferCtxtExt, ObligationCtxt}; use crate::{LateContext, LateLintPass}; -declare_lint! { - /// Docs - pub REDUNDANT_LIFETIME_ARGS, - Allow, - "do something" -} - -declare_lint_pass!(RedundantLifetimeArgs => [REDUNDANT_LIFETIME_ARGS]); +declare_lint_pass!(RedundantLifetimeArgs => []); impl<'tcx> LateLintPass<'tcx> for RedundantLifetimeArgs { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { @@ -142,10 +136,10 @@ fn check<'tcx>(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, owner_id: hir:: if infcx.resolve_regions(outlives_env).is_empty() { shadowed.insert(victim); tcx.emit_spanned_lint( - REDUNDANT_LIFETIME_ARGS, + UNUSED_LIFETIMES, tcx.local_def_id_to_hir_id(def_id.expect_local()), tcx.def_span(def_id), - RedundantLifetimeArgsList { candidate, victim }, + RedundantLifetimeArgsLint { candidate, victim }, ); } } @@ -154,7 +148,8 @@ fn check<'tcx>(tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, owner_id: hir:: #[derive(LintDiagnostic)] #[diag(lint_redundant_lifetime_args)] -struct RedundantLifetimeArgsList<'tcx> { +#[note] +struct RedundantLifetimeArgsLint<'tcx> { candidate: ty::Region<'tcx>, victim: ty::Region<'tcx>, } |
