diff options
| author | bors <bors@rust-lang.org> | 2023-02-22 12:04:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-22 12:04:45 +0000 |
| commit | 3b4d6e080404560f63599deeb328dfa27fe081a6 (patch) | |
| tree | 0404fed1412000d50e1807cda997649437aa7220 /compiler/rustc_hir_analysis/src | |
| parent | bd4a96a12d0bf6dc12edf20a45df3a33052c9d7d (diff) | |
| parent | 0d0de4971e2b134549f5e8019cbc06dadc5596ca (diff) | |
| download | rust-3b4d6e080404560f63599deeb328dfa27fe081a6.tar.gz rust-3b4d6e080404560f63599deeb328dfa27fe081a6.zip | |
Auto merge of #108339 - GuillaumeGomez:rollup-4z02kas, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #108110 (Move some `InferCtxt` methods to `EvalCtxt` in new solver) - #108168 (Fix ICE on type alias in recursion) - #108230 (Convert a hard-warning about named static lifetimes into lint "unused_lifetimes") - #108239 (Fix overlapping spans in removing extra arguments) - #108246 (Add an InstCombine for redundant casts) - #108264 (no-fail-fast support for tool testsuites) - #108310 (rustdoc: Fix duplicated attributes for first reexport) - #108318 (Remove unused FileDesc::get_cloexec) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs | 46 |
1 files changed, 24 insertions, 22 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 c0c90e47a75..e977767e024 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -18,6 +18,7 @@ use rustc_middle::bug; use rustc_middle::hir::nested_filter; use rustc_middle::middle::resolve_bound_vars::*; use rustc_middle::ty::{self, ir::TypeVisitor, DefIdTree, TyCtxt, TypeSuperVisitable}; +use rustc_session::lint; use rustc_span::def_id::DefId; use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; @@ -923,17 +924,16 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { origin, .. }) => { - let (bound_vars, binders): (FxIndexMap<LocalDefId, ResolvedArg>, Vec<_>) = bound_generic_params - .iter() - .enumerate() - .map(|(late_bound_idx, param)| { - let pair = ResolvedArg::late(late_bound_idx as u32, param); - let r = late_arg_as_bound_arg(this.tcx, &pair.1, param); - (pair, r) - }) - .unzip(); + .iter() + .enumerate() + .map(|(late_bound_idx, param)| { + let pair = ResolvedArg::late(late_bound_idx as u32, param); + let r = late_arg_as_bound_arg(this.tcx, &pair.1, param); + (pair, r) + }) + .unzip(); this.record_late_bound_vars(hir_id, binders.clone()); // Even if there are no lifetimes defined here, we still wrap it in a binder // scope. If there happens to be a nested poly trait ref (an error), that @@ -968,20 +968,22 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { continue; } this.insert_lifetime(lt, ResolvedArg::StaticLifetime); - this.tcx - .sess - .struct_span_warn( - lifetime.ident.span, - &format!( - "unnecessary lifetime parameter `{}`", + this.tcx.struct_span_lint_hir( + 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, - ), - ) - .help(&format!( - "you can use the `'static` lifetime directly, in place of `{}`", - lifetime.ident, - )) - .emit(); + ); + lint.help(help) + }, + ); } } } |
