Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit bacbf46

Browse files
committed
TyCtxt::item_name exists
1 parent 610f1a5 commit bacbf46

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
16431643
for lifetime in captured_lifetimes_to_duplicate {
16441644
let res = self.resolver.get_lifetime_res(lifetime.id).unwrap_or(LifetimeRes::Error);
16451645
let (old_def_id, missing_kind) = match res {
1646-
LifetimeRes::Param { param: (old_def_id, _), binder: _ } => (old_def_id, None),
1646+
LifetimeRes::Param { param: old_def_id, binder: _ } => (old_def_id, None),
16471647

16481648
LifetimeRes::Fresh { param, kind, .. } => {
16491649
debug_assert_eq!(lifetime.ident.name, kw::UnderscoreLifetime);
@@ -2061,7 +2061,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20612061
res: LifetimeRes,
20622062
) -> &'hir hir::Lifetime {
20632063
let res = match res {
2064-
LifetimeRes::Param { param: (param, _), .. } => {
2064+
LifetimeRes::Param { param, .. } => {
20652065
let param = self.get_remapped_def_id(param);
20662066
hir::LifetimeName::Param(param)
20672067
}

compiler/rustc_hir/src/def.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_data_structures::unord::UnordMap;
88
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
99
use rustc_span::def_id::{DefId, LocalDefId};
1010
use rustc_span::hygiene::MacroKind;
11-
use rustc_span::symbol::{kw, Ident};
11+
use rustc_span::symbol::kw;
1212
use rustc_span::Symbol;
1313

1414
use crate::definitions::DefPathData;
@@ -796,8 +796,8 @@ impl<Id> Res<Id> {
796796
pub enum LifetimeRes {
797797
/// Successfully linked the lifetime to a generic parameter.
798798
Param {
799-
/// `LocalDefId` & `Ident` of the generic parameter that introduced it.
800-
param: (LocalDefId, Ident),
799+
/// Id of the generic parameter that introduced it.
800+
param: LocalDefId,
801801
/// Id of the introducing place. That can be:
802802
/// - an item's id, for the item's generic parameters;
803803
/// - a TraitRef's ref_id, identifying the `for<...>` binder;

compiler/rustc_lint/src/context/diagnostics.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,13 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &
446446
lints::ElidedNamedLifetime { elided, name: kw::StaticLifetime, named_declaration: None }
447447
.decorate_lint(diag)
448448
}
449-
BuiltinLintDiag::ElidedIsParam { elided, param } => lints::ElidedNamedLifetime {
450-
elided,
451-
name: param.name,
452-
named_declaration: Some(param.span),
449+
BuiltinLintDiag::ElidedIsParam { elided, param: (param_name, param_span) } => {
450+
lints::ElidedNamedLifetime {
451+
elided,
452+
name: param_name,
453+
named_declaration: Some(param_span),
454+
}
455+
.decorate_lint(diag)
453456
}
454-
.decorate_lint(diag),
455457
}
456458
}

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ pub enum BuiltinLintDiag {
590590
},
591591
ElidedIsParam {
592592
elided: Span,
593-
param: Ident,
593+
param: (Symbol, Span),
594594
},
595595
UnknownCrateTypes {
596596
span: Span,

compiler/rustc_resolve/src/late.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,7 +1598,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
15981598
if let Some(&(_, res)) = rib.bindings.get(&normalized_ident) {
15991599
self.record_lifetime_res(lifetime.id, res, LifetimeElisionCandidate::Named);
16001600

1601-
if let LifetimeRes::Param { param: (param, _), binder } = res {
1601+
if let LifetimeRes::Param { param, binder } = res {
16021602
match self.lifetime_uses.entry(param) {
16031603
Entry::Vacant(v) => {
16041604
debug!("First use of {:?} at {:?}", res, ident.span);
@@ -2079,7 +2079,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20792079
);
20802080
}
20812081
}
2082-
LifetimeRes::Param { param: (_, param), binder } => {
2082+
LifetimeRes::Param { param, binder } => {
2083+
let tcx = self.r.tcx();
20832084
self.r.lint_buffer.buffer_lint(
20842085
lint::builtin::ELIDED_NAMED_LIFETIMES,
20852086
// It should be possible to use `self.crate_node_id`
@@ -2089,7 +2090,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20892090
// we would have to do some additional work.
20902091
missing.id_if_exists_in_source_or(binder),
20912092
missing.span,
2092-
BuiltinLintDiag::ElidedIsParam { elided, param },
2093+
BuiltinLintDiag::ElidedIsParam {
2094+
elided,
2095+
param: (tcx.item_name(param.into()), tcx.source_span(param)),
2096+
},
20932097
);
20942098
}
20952099
LifetimeRes::Fresh { .. }
@@ -2824,7 +2828,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
28242828
(&mut function_value_rib, DefKind::ConstParam)
28252829
}
28262830
GenericParamKind::Lifetime => {
2827-
let res = LifetimeRes::Param { param: (def_id, param.ident), binder };
2831+
let res = LifetimeRes::Param { param: def_id, binder };
28282832
self.record_lifetime_param(param.id, res);
28292833
function_lifetime_rib.bindings.insert(ident, (param.id, res));
28302834
continue;

0 commit comments

Comments
 (0)