Rename some name variables as ident.

It bugs me when variables of type `Ident` are called `name`. It leads to
silly things like `name.name`. `Ident` variables should be called
`ident`, and `name` should be used for variables of type `Symbol`.

This commit improves things by by doing `s/name/ident/` on a bunch of
`Ident` variables. Not all of them, but a decent chunk.
This commit is contained in:
Nicholas Nethercote 2025-04-08 12:23:07 +10:00
parent d4f880f8ce
commit 1b3fc585cb
52 changed files with 238 additions and 229 deletions

View File

@ -13,12 +13,12 @@ pub mod typetree;
#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)] #[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)]
pub struct StrippedCfgItem<ModId = DefId> { pub struct StrippedCfgItem<ModId = DefId> {
pub parent_module: ModId, pub parent_module: ModId,
pub name: Ident, pub ident: Ident,
pub cfg: MetaItem, pub cfg: MetaItem,
} }
impl<ModId> StrippedCfgItem<ModId> { impl<ModId> StrippedCfgItem<ModId> {
pub fn map_mod_id<New>(self, f: impl FnOnce(ModId) -> New) -> StrippedCfgItem<New> { pub fn map_mod_id<New>(self, f: impl FnOnce(ModId) -> New) -> StrippedCfgItem<New> {
StrippedCfgItem { parent_module: f(self.parent_module), name: self.name, cfg: self.cfg } StrippedCfgItem { parent_module: f(self.parent_module), ident: self.ident, cfg: self.cfg }
} }
} }

View File

@ -645,7 +645,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
( (
// Disallow `impl Trait` in foreign items. // Disallow `impl Trait` in foreign items.
this.lower_fn_decl(fdec, i.id, sig.span, FnDeclKind::ExternFn, None), this.lower_fn_decl(fdec, i.id, sig.span, FnDeclKind::ExternFn, None),
this.lower_fn_params_to_names(fdec), this.lower_fn_params_to_idents(fdec),
) )
}); });
@ -833,7 +833,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
}) => { }) => {
// FIXME(contracts): Deny contract here since it won't apply to // FIXME(contracts): Deny contract here since it won't apply to
// any impl method or callees. // any impl method or callees.
let names = self.lower_fn_params_to_names(&sig.decl); let idents = self.lower_fn_params_to_idents(&sig.decl);
let (generics, sig) = self.lower_method_sig( let (generics, sig) = self.lower_method_sig(
generics, generics,
sig, sig,
@ -851,7 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
( (
*ident, *ident,
generics, generics,
hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(names)), hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(idents)),
false, false,
) )
} }

View File

@ -1247,7 +1247,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
safety: self.lower_safety(f.safety, hir::Safety::Safe), safety: self.lower_safety(f.safety, hir::Safety::Safe),
abi: self.lower_extern(f.ext), abi: self.lower_extern(f.ext),
decl: self.lower_fn_decl(&f.decl, t.id, t.span, FnDeclKind::Pointer, None), decl: self.lower_fn_decl(&f.decl, t.id, t.span, FnDeclKind::Pointer, None),
param_names: self.lower_fn_params_to_names(&f.decl), param_idents: self.lower_fn_params_to_idents(&f.decl),
})) }))
} }
TyKind::UnsafeBinder(f) => { TyKind::UnsafeBinder(f) => {
@ -1494,7 +1494,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
})) }))
} }
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] { fn lower_fn_params_to_idents(&mut self, decl: &FnDecl) -> &'hir [Option<Ident>] {
self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind { self.arena.alloc_from_iter(decl.inputs.iter().map(|param| match param.pat.kind {
PatKind::Missing => None, PatKind::Missing => None,
PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)), PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),

View File

@ -7,12 +7,12 @@ use super::*;
fn fun_to_string( fn fun_to_string(
decl: &ast::FnDecl, decl: &ast::FnDecl,
header: ast::FnHeader, header: ast::FnHeader,
name: Ident, ident: Ident,
generics: &ast::Generics, generics: &ast::Generics,
) -> String { ) -> String {
to_string(|s| { to_string(|s| {
s.head(""); s.head("");
s.print_fn(decl, header, Some(name), generics); s.print_fn(decl, header, Some(ident), generics);
s.end(); // Close the head box. s.end(); // Close the head box.
s.end(); // Close the outer box. s.end(); // Close the outer box.
}) })

View File

@ -2500,11 +2500,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
); );
let ty::Tuple(params) = tupled_params.kind() else { return }; let ty::Tuple(params) = tupled_params.kind() else { return };
// Find the first argument with a matching type, get its name // Find the first argument with a matching type, get its ident
let Some(this_name) = params.iter().zip(tcx.hir_body_param_names(closure.body)).find_map( let Some(this_name) = params.iter().zip(tcx.hir_body_param_idents(closure.body)).find_map(
|(param_ty, name)| { |(param_ty, ident)| {
// FIXME: also support deref for stuff like `Rc` arguments // FIXME: also support deref for stuff like `Rc` arguments
if param_ty.peel_refs() == local_ty { name } else { None } if param_ty.peel_refs() == local_ty { ident } else { None }
}, },
) else { ) else {
return; return;
@ -3774,7 +3774,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
method_args, method_args,
*fn_span, *fn_span,
call_source.from_hir_call(), call_source.from_hir_call(),
self.infcx.tcx.fn_arg_names(method_did)[0], self.infcx.tcx.fn_arg_idents(method_did)[0],
) )
{ {
err.note(format!("borrow occurs due to deref coercion to `{deref_target_ty}`")); err.note(format!("borrow occurs due to deref coercion to `{deref_target_ty}`"));

View File

@ -1029,7 +1029,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
method_args, method_args,
*fn_span, *fn_span,
call_source.from_hir_call(), call_source.from_hir_call(),
self.infcx.tcx.fn_arg_names(method_did)[0], self.infcx.tcx.fn_arg_idents(method_did)[0],
); );
return FnSelfUse { return FnSelfUse {

View File

@ -20,14 +20,14 @@ use crate::errors;
struct ProcMacroDerive { struct ProcMacroDerive {
id: NodeId, id: NodeId,
trait_name: Symbol, trait_name: Symbol,
function_name: Ident, function_ident: Ident,
span: Span, span: Span,
attrs: Vec<Symbol>, attrs: Vec<Symbol>,
} }
struct ProcMacroDef { struct ProcMacroDef {
id: NodeId, id: NodeId,
function_name: Ident, function_ident: Ident,
span: Span, span: Span,
} }
@ -95,7 +95,7 @@ impl<'a> CollectProcMacros<'a> {
fn collect_custom_derive( fn collect_custom_derive(
&mut self, &mut self,
item: &'a ast::Item, item: &'a ast::Item,
function_name: Ident, function_ident: Ident,
attr: &'a ast::Attribute, attr: &'a ast::Attribute,
) { ) {
let Some((trait_name, proc_attrs)) = let Some((trait_name, proc_attrs)) =
@ -109,7 +109,7 @@ impl<'a> CollectProcMacros<'a> {
id: item.id, id: item.id,
span: item.span, span: item.span,
trait_name, trait_name,
function_name, function_ident,
attrs: proc_attrs, attrs: proc_attrs,
})); }));
} else { } else {
@ -123,12 +123,12 @@ impl<'a> CollectProcMacros<'a> {
} }
} }
fn collect_attr_proc_macro(&mut self, item: &'a ast::Item, function_name: Ident) { fn collect_attr_proc_macro(&mut self, item: &'a ast::Item, function_ident: Ident) {
if self.in_root && item.vis.kind.is_pub() { if self.in_root && item.vis.kind.is_pub() {
self.macros.push(ProcMacro::Attr(ProcMacroDef { self.macros.push(ProcMacro::Attr(ProcMacroDef {
id: item.id, id: item.id,
span: item.span, span: item.span,
function_name, function_ident,
})); }));
} else { } else {
let msg = if !self.in_root { let msg = if !self.in_root {
@ -141,12 +141,12 @@ impl<'a> CollectProcMacros<'a> {
} }
} }
fn collect_bang_proc_macro(&mut self, item: &'a ast::Item, function_name: Ident) { fn collect_bang_proc_macro(&mut self, item: &'a ast::Item, function_ident: Ident) {
if self.in_root && item.vis.kind.is_pub() { if self.in_root && item.vis.kind.is_pub() {
self.macros.push(ProcMacro::Bang(ProcMacroDef { self.macros.push(ProcMacro::Bang(ProcMacroDef {
id: item.id, id: item.id,
span: item.span, span: item.span,
function_name, function_ident,
})); }));
} else { } else {
let msg = if !self.in_root { let msg = if !self.in_root {
@ -303,7 +303,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
ProcMacro::Derive(m) => m.span, ProcMacro::Derive(m) => m.span,
ProcMacro::Attr(m) | ProcMacro::Bang(m) => m.span, ProcMacro::Attr(m) | ProcMacro::Bang(m) => m.span,
}; };
let local_path = |cx: &ExtCtxt<'_>, name| cx.expr_path(cx.path(span, vec![name])); let local_path = |cx: &ExtCtxt<'_>, ident| cx.expr_path(cx.path(span, vec![ident]));
let proc_macro_ty_method_path = |cx: &ExtCtxt<'_>, method| { let proc_macro_ty_method_path = |cx: &ExtCtxt<'_>, method| {
cx.expr_path(cx.path( cx.expr_path(cx.path(
span.with_ctxt(harness_span.ctxt()), span.with_ctxt(harness_span.ctxt()),
@ -327,7 +327,7 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
.map(|&s| cx.expr_str(span, s)) .map(|&s| cx.expr_str(span, s))
.collect::<ThinVec<_>>(), .collect::<ThinVec<_>>(),
), ),
local_path(cx, cd.function_name), local_path(cx, cd.function_ident),
], ],
) )
} }
@ -345,8 +345,8 @@ fn mk_decls(cx: &mut ExtCtxt<'_>, macros: &[ProcMacro]) -> P<ast::Item> {
harness_span, harness_span,
proc_macro_ty_method_path(cx, ident), proc_macro_ty_method_path(cx, ident),
thin_vec![ thin_vec![
cx.expr_str(span, ca.function_name.name), cx.expr_str(span, ca.function_ident.name),
local_path(cx, ca.function_name), local_path(cx, ca.function_ident),
], ],
) )
} }

View File

@ -104,7 +104,7 @@ pub(crate) fn maybe_create_entry_wrapper(
let termination_trait = tcx.require_lang_item(LangItem::Termination, None); let termination_trait = tcx.require_lang_item(LangItem::Termination, None);
let report = tcx let report = tcx
.associated_items(termination_trait) .associated_items(termination_trait)
.find_by_name_and_kind( .find_by_ident_and_kind(
tcx, tcx,
Ident::from_str("report"), Ident::from_str("report"),
AssocKind::Fn, AssocKind::Fn,

View File

@ -1102,7 +1102,7 @@ pub trait ResolverExpand {
/// HIR proc macros items back to their harness items. /// HIR proc macros items back to their harness items.
fn declare_proc_macro(&mut self, id: NodeId); fn declare_proc_macro(&mut self, id: NodeId);
fn append_stripped_cfg_item(&mut self, parent_node: NodeId, name: Ident, cfg: ast::MetaItem); fn append_stripped_cfg_item(&mut self, parent_node: NodeId, ident: Ident, cfg: ast::MetaItem);
/// Tools registered with `#![register_tool]` and used by tool attributes and lints. /// Tools registered with `#![register_tool]` and used by tool attributes and lints.
fn registered_tools(&self) -> &RegisteredTools; fn registered_tools(&self) -> &RegisteredTools;

View File

@ -1169,9 +1169,9 @@ trait InvocationCollectorNode: HasAttrs + HasNodeId + Sized {
collector.cx.dcx().emit_err(RemoveNodeNotSupported { span, descr: Self::descr() }); collector.cx.dcx().emit_err(RemoveNodeNotSupported { span, descr: Self::descr() });
} }
/// All of the names (items) declared by this node. /// All of the idents (items) declared by this node.
/// This is an approximation and should only be used for diagnostics. /// This is an approximation and should only be used for diagnostics.
fn declared_names(&self) -> Vec<Ident> { fn declared_idents(&self) -> Vec<Ident> {
vec![] vec![]
} }
} }
@ -1306,7 +1306,7 @@ impl InvocationCollectorNode for P<ast::Item> {
res res
} }
fn declared_names(&self) -> Vec<Ident> { fn declared_idents(&self) -> Vec<Ident> {
if let ItemKind::Use(ut) = &self.kind { if let ItemKind::Use(ut) = &self.kind {
fn collect_use_tree_leaves(ut: &ast::UseTree, idents: &mut Vec<Ident>) { fn collect_use_tree_leaves(ut: &ast::UseTree, idents: &mut Vec<Ident>) {
match &ut.kind { match &ut.kind {
@ -2061,10 +2061,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
} }
if let Some(meta_item) = meta_item { if let Some(meta_item) = meta_item {
for name in node.declared_names() { for ident in node.declared_idents() {
self.cx.resolver.append_stripped_cfg_item( self.cx.resolver.append_stripped_cfg_item(
self.cx.current_expansion.lint_node_id, self.cx.current_expansion.lint_node_id,
name, ident,
meta_item.clone(), meta_item.clone(),
) )
} }

View File

@ -3399,9 +3399,9 @@ pub struct BareFnTy<'hir> {
pub abi: ExternAbi, pub abi: ExternAbi,
pub generic_params: &'hir [GenericParam<'hir>], pub generic_params: &'hir [GenericParam<'hir>],
pub decl: &'hir FnDecl<'hir>, pub decl: &'hir FnDecl<'hir>,
// `Option` because bare fn parameter names are optional. We also end up // `Option` because bare fn parameter idents are optional. We also end up
// with `None` in some error cases, e.g. invalid parameter patterns. // with `None` in some error cases, e.g. invalid parameter patterns.
pub param_names: &'hir [Option<Ident>], pub param_idents: &'hir [Option<Ident>],
} }
#[derive(Debug, Clone, Copy, HashStable_Generic)] #[derive(Debug, Clone, Copy, HashStable_Generic)]

View File

@ -652,10 +652,10 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
try_visit!(visitor.visit_ident(foreign_item.ident)); try_visit!(visitor.visit_ident(foreign_item.ident));
match foreign_item.kind { match foreign_item.kind {
ForeignItemKind::Fn(ref sig, param_names, ref generics) => { ForeignItemKind::Fn(ref sig, param_idents, ref generics) => {
try_visit!(visitor.visit_generics(generics)); try_visit!(visitor.visit_generics(generics));
try_visit!(visitor.visit_fn_decl(sig.decl)); try_visit!(visitor.visit_fn_decl(sig.decl));
for ident in param_names.iter().copied() { for ident in param_idents.iter().copied() {
visit_opt!(visitor, visit_ident, ident); visit_opt!(visitor, visit_ident, ident);
} }
} }
@ -1169,9 +1169,9 @@ pub fn walk_trait_item<'v, V: Visitor<'v>>(
try_visit!(visitor.visit_ty_unambig(ty)); try_visit!(visitor.visit_ty_unambig(ty));
visit_opt!(visitor, visit_nested_body, default); visit_opt!(visitor, visit_nested_body, default);
} }
TraitItemKind::Fn(ref sig, TraitFn::Required(param_names)) => { TraitItemKind::Fn(ref sig, TraitFn::Required(param_idents)) => {
try_visit!(visitor.visit_fn_decl(sig.decl)); try_visit!(visitor.visit_fn_decl(sig.decl));
for ident in param_names.iter().copied() { for ident in param_idents.iter().copied() {
visit_opt!(visitor, visit_ident, ident); visit_opt!(visitor, visit_ident, ident);
} }
} }

View File

@ -1,5 +1,5 @@
hir_analysis_ambiguous_assoc_item = ambiguous associated {$assoc_kind} `{$assoc_name}` in bounds of `{$qself}` hir_analysis_ambiguous_assoc_item = ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`
.label = ambiguous associated {$assoc_kind} `{$assoc_name}` .label = ambiguous associated {$assoc_kind} `{$assoc_ident}`
hir_analysis_ambiguous_lifetime_bound = hir_analysis_ambiguous_lifetime_bound =
ambiguous lifetime bound, explicit lifetime bound required ambiguous lifetime bound, explicit lifetime bound required
@ -12,13 +12,13 @@ hir_analysis_assoc_item_is_private = {$kind} `{$name}` is private
.label = private {$kind} .label = private {$kind}
.defined_here_label = the {$kind} is defined here .defined_here_label = the {$kind} is defined here
hir_analysis_assoc_item_not_found = associated {$assoc_kind} `{$assoc_name}` not found for `{$qself}` hir_analysis_assoc_item_not_found = associated {$assoc_kind} `{$assoc_ident}` not found for `{$qself}`
hir_analysis_assoc_item_not_found_found_in_other_trait_label = there is {$identically_named -> hir_analysis_assoc_item_not_found_found_in_other_trait_label = there is {$identically_named ->
[true] an [true] an
*[false] a similarly named *[false] a similarly named
} associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}` } associated {$assoc_kind} `{$suggested_name}` in the trait `{$trait_name}`
hir_analysis_assoc_item_not_found_label = associated {$assoc_kind} `{$assoc_name}` not found hir_analysis_assoc_item_not_found_label = associated {$assoc_kind} `{$assoc_ident}` not found
hir_analysis_assoc_item_not_found_other_sugg = `{$qself}` has the following associated {$assoc_kind} hir_analysis_assoc_item_not_found_other_sugg = `{$qself}` has the following associated {$assoc_kind}
hir_analysis_assoc_item_not_found_similar_in_other_trait_qpath_sugg = hir_analysis_assoc_item_not_found_similar_in_other_trait_qpath_sugg =
consider fully qualifying{$identically_named -> consider fully qualifying{$identically_named ->

View File

@ -1046,11 +1046,11 @@ fn report_trait_method_mismatch<'tcx>(
// argument pattern and type. // argument pattern and type.
let (sig, body) = tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn(); let (sig, body) = tcx.hir_expect_impl_item(impl_m.def_id.expect_local()).expect_fn();
let span = tcx let span = tcx
.hir_body_param_names(body) .hir_body_param_idents(body)
.zip(sig.decl.inputs.iter()) .zip(sig.decl.inputs.iter())
.map(|(param_name, ty)| { .map(|(param_ident, ty)| {
if let Some(param_name) = param_name { if let Some(param_ident) = param_ident {
param_name.span.to(ty.span) param_ident.span.to(ty.span)
} else { } else {
ty.span ty.span
} }

View File

@ -438,9 +438,9 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
&self, &self,
span: Span, span: Span,
def_id: LocalDefId, def_id: LocalDefId,
assoc_name: Ident, assoc_ident: Ident,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
self.tcx.at(span).type_param_predicates((self.item_def_id, def_id, assoc_name)) self.tcx.at(span).type_param_predicates((self.item_def_id, def_id, assoc_ident))
} }
fn lower_assoc_shared( fn lower_assoc_shared(

View File

@ -584,12 +584,12 @@ pub(super) fn explicit_super_predicates_of<'tcx>(
pub(super) fn explicit_supertraits_containing_assoc_item<'tcx>( pub(super) fn explicit_supertraits_containing_assoc_item<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
(trait_def_id, assoc_name): (DefId, Ident), (trait_def_id, assoc_ident): (DefId, Ident),
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
implied_predicates_with_filter( implied_predicates_with_filter(
tcx, tcx,
trait_def_id, trait_def_id,
PredicateFilter::SelfTraitThatDefines(assoc_name), PredicateFilter::SelfTraitThatDefines(assoc_ident),
) )
} }
@ -617,7 +617,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
filter: PredicateFilter, filter: PredicateFilter,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
let Some(trait_def_id) = trait_def_id.as_local() else { let Some(trait_def_id) = trait_def_id.as_local() else {
// if `assoc_name` is None, then the query should've been redirected to an // if `assoc_ident` is None, then the query should've been redirected to an
// external provider // external provider
assert_matches!(filter, PredicateFilter::SelfTraitThatDefines(_)); assert_matches!(filter, PredicateFilter::SelfTraitThatDefines(_));
return tcx.explicit_super_predicates_of(trait_def_id); return tcx.explicit_super_predicates_of(trait_def_id);
@ -834,11 +834,11 @@ pub(super) fn assert_only_contains_predicates_from<'tcx>(
#[instrument(level = "trace", skip(tcx))] #[instrument(level = "trace", skip(tcx))]
pub(super) fn type_param_predicates<'tcx>( pub(super) fn type_param_predicates<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
(item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident), (item_def_id, def_id, assoc_ident): (LocalDefId, LocalDefId, Ident),
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> { ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
match tcx.opt_rpitit_info(item_def_id.to_def_id()) { match tcx.opt_rpitit_info(item_def_id.to_def_id()) {
Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => { Some(ty::ImplTraitInTraitData::Trait { opaque_def_id, .. }) => {
return tcx.type_param_predicates((opaque_def_id.expect_local(), def_id, assoc_name)); return tcx.type_param_predicates((opaque_def_id.expect_local(), def_id, assoc_ident));
} }
Some(ty::ImplTraitInTraitData::Impl { .. }) => { Some(ty::ImplTraitInTraitData::Impl { .. }) => {
unreachable!("should not be lowering bounds on RPITIT in impl") unreachable!("should not be lowering bounds on RPITIT in impl")
@ -863,7 +863,7 @@ pub(super) fn type_param_predicates<'tcx>(
let result = if let Some(parent) = parent { let result = if let Some(parent) = parent {
let icx = ItemCtxt::new(tcx, parent); let icx = ItemCtxt::new(tcx, parent);
icx.probe_ty_param_bounds(DUMMY_SP, def_id, assoc_name) icx.probe_ty_param_bounds(DUMMY_SP, def_id, assoc_ident)
} else { } else {
ty::EarlyBinder::bind(&[] as &[_]) ty::EarlyBinder::bind(&[] as &[_])
}; };
@ -889,7 +889,7 @@ pub(super) fn type_param_predicates<'tcx>(
let extra_predicates = extend.into_iter().chain(icx.probe_ty_param_bounds_in_generics( let extra_predicates = extend.into_iter().chain(icx.probe_ty_param_bounds_in_generics(
hir_generics, hir_generics,
def_id, def_id,
PredicateFilter::SelfTraitThatDefines(assoc_name), PredicateFilter::SelfTraitThatDefines(assoc_ident),
)); ));
let bounds = let bounds =
@ -908,7 +908,7 @@ pub(super) fn type_param_predicates<'tcx>(
_ => unreachable!(), _ => unreachable!(),
}; };
assert_only_contains_predicates_from( assert_only_contains_predicates_from(
PredicateFilter::SelfTraitThatDefines(assoc_name), PredicateFilter::SelfTraitThatDefines(assoc_ident),
bounds, bounds,
self_ty, self_ty,
); );

View File

@ -1874,13 +1874,13 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
fn supertrait_hrtb_vars( fn supertrait_hrtb_vars(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
def_id: DefId, def_id: DefId,
assoc_name: Ident, assoc_ident: Ident,
assoc_kind: ty::AssocKind, assoc_kind: ty::AssocKind,
) -> Option<(Vec<ty::BoundVariableKind>, &'tcx ty::AssocItem)> { ) -> Option<(Vec<ty::BoundVariableKind>, &'tcx ty::AssocItem)> {
let trait_defines_associated_item_named = |trait_def_id: DefId| { let trait_defines_associated_item_named = |trait_def_id: DefId| {
tcx.associated_items(trait_def_id).find_by_name_and_kind( tcx.associated_items(trait_def_id).find_by_ident_and_kind(
tcx, tcx,
assoc_name, assoc_ident,
assoc_kind, assoc_kind,
trait_def_id, trait_def_id,
) )
@ -1904,7 +1904,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
if let Some(assoc_item) = trait_defines_associated_item_named(def_id) { if let Some(assoc_item) = trait_defines_associated_item_named(def_id) {
break Some((bound_vars.into_iter().collect(), assoc_item)); break Some((bound_vars.into_iter().collect(), assoc_item));
} }
let predicates = tcx.explicit_supertraits_containing_assoc_item((def_id, assoc_name)); let predicates = tcx.explicit_supertraits_containing_assoc_item((def_id, assoc_ident));
let obligations = predicates.iter_identity_copied().filter_map(|(pred, _)| { let obligations = predicates.iter_identity_copied().filter_map(|(pred, _)| {
let bound_predicate = pred.kind(); let bound_predicate = pred.kind();
match bound_predicate.skip_binder() { match bound_predicate.skip_binder() {

View File

@ -23,7 +23,7 @@ pub(crate) struct AmbiguousAssocItem<'a> {
#[label] #[label]
pub span: Span, pub span: Span,
pub assoc_kind: &'static str, pub assoc_kind: &'static str,
pub assoc_name: Ident, pub assoc_ident: Ident,
pub qself: &'a str, pub qself: &'a str,
} }
@ -75,7 +75,7 @@ pub(crate) struct AssocItemIsPrivate {
pub(crate) struct AssocItemNotFound<'a> { pub(crate) struct AssocItemNotFound<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub assoc_name: Ident, pub assoc_ident: Ident,
pub assoc_kind: &'static str, pub assoc_kind: &'static str,
pub qself: &'a str, pub qself: &'a str,
#[subdiagnostic] #[subdiagnostic]

View File

@ -363,10 +363,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
for hir_bound in hir_bounds { for hir_bound in hir_bounds {
// In order to avoid cycles, when we're lowering `SelfTraitThatDefines`, // In order to avoid cycles, when we're lowering `SelfTraitThatDefines`,
// we skip over any traits that don't define the given associated type. // we skip over any traits that don't define the given associated type.
if let PredicateFilter::SelfTraitThatDefines(assoc_name) = predicate_filter { if let PredicateFilter::SelfTraitThatDefines(assoc_ident) = predicate_filter {
if let Some(trait_ref) = hir_bound.trait_ref() if let Some(trait_ref) = hir_bound.trait_ref()
&& let Some(trait_did) = trait_ref.trait_def_id() && let Some(trait_did) = trait_ref.trait_def_id()
&& self.tcx().trait_may_define_assoc_item(trait_did, assoc_name) && self.tcx().trait_may_define_assoc_item(trait_did, assoc_ident)
{ {
// Okay // Okay
} else { } else {

View File

@ -49,13 +49,13 @@ pub(crate) fn validate_cmse_abi<'tcx>(
Ok(Err(index)) => { Ok(Err(index)) => {
// fn(x: u32, u32, u32, u16, y: u16) -> u32, // fn(x: u32, u32, u32, u16, y: u16) -> u32,
// ^^^^^^ // ^^^^^^
let span = if let Some(ident) = bare_fn_ty.param_names[index] { let span = if let Some(ident) = bare_fn_ty.param_idents[index] {
ident.span.to(bare_fn_ty.decl.inputs[index].span) ident.span.to(bare_fn_ty.decl.inputs[index].span)
} else { } else {
bare_fn_ty.decl.inputs[index].span bare_fn_ty.decl.inputs[index].span
} }
.to(bare_fn_ty.decl.inputs.last().unwrap().span); .to(bare_fn_ty.decl.inputs.last().unwrap().span);
let plural = bare_fn_ty.param_names.len() - index != 1; let plural = bare_fn_ty.param_idents.len() - index != 1;
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi }); dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
} }
Err(layout_err) => { Err(layout_err) => {

View File

@ -117,7 +117,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
all_candidates: impl Fn() -> I, all_candidates: impl Fn() -> I,
qself: AssocItemQSelf, qself: AssocItemQSelf,
assoc_kind: ty::AssocKind, assoc_kind: ty::AssocKind,
assoc_name: Ident, assoc_ident: Ident,
span: Span, span: Span,
constraint: Option<&hir::AssocItemConstraint<'tcx>>, constraint: Option<&hir::AssocItemConstraint<'tcx>>,
) -> ErrorGuaranteed ) -> ErrorGuaranteed
@ -129,11 +129,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// First and foremost, provide a more user-friendly & “intuitive” error on kind mismatches. // First and foremost, provide a more user-friendly & “intuitive” error on kind mismatches.
if let Some(assoc_item) = all_candidates().find_map(|r| { if let Some(assoc_item) = all_candidates().find_map(|r| {
tcx.associated_items(r.def_id()) tcx.associated_items(r.def_id())
.filter_by_name_unhygienic(assoc_name.name) .filter_by_name_unhygienic(assoc_ident.name)
.find(|item| tcx.hygienic_eq(assoc_name, item.ident(tcx), r.def_id())) .find(|item| tcx.hygienic_eq(assoc_ident, item.ident(tcx), r.def_id()))
}) { }) {
return self.complain_about_assoc_kind_mismatch( return self.complain_about_assoc_kind_mismatch(
assoc_item, assoc_kind, assoc_name, span, constraint, assoc_item,
assoc_kind,
assoc_ident,
span,
constraint,
); );
} }
@ -142,18 +146,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// The fallback span is needed because `assoc_name` might be an `Fn()`'s `Output` without a // The fallback span is needed because `assoc_name` might be an `Fn()`'s `Output` without a
// valid span, so we point at the whole path segment instead. // valid span, so we point at the whole path segment instead.
let is_dummy = assoc_name.span == DUMMY_SP; let is_dummy = assoc_ident.span == DUMMY_SP;
let mut err = errors::AssocItemNotFound { let mut err = errors::AssocItemNotFound {
span: if is_dummy { span } else { assoc_name.span }, span: if is_dummy { span } else { assoc_ident.span },
assoc_name, assoc_ident,
assoc_kind: assoc_kind_str, assoc_kind: assoc_kind_str,
qself: &qself_str, qself: &qself_str,
label: None, label: None,
sugg: None, sugg: None,
// Try to get the span of the identifier within the path's syntax context // Try to get the span of the identifier within the path's syntax context
// (if that's different). // (if that's different).
within_macro_span: assoc_name.span.within_macro(span, tcx.sess.source_map()), within_macro_span: assoc_ident.span.within_macro(span, tcx.sess.source_map()),
}; };
if is_dummy { if is_dummy {
@ -169,10 +173,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.collect(); .collect();
if let Some(suggested_name) = if let Some(suggested_name) =
find_best_match_for_name(&all_candidate_names, assoc_name.name, None) find_best_match_for_name(&all_candidate_names, assoc_ident.name, None)
{ {
err.sugg = Some(errors::AssocItemNotFoundSugg::Similar { err.sugg = Some(errors::AssocItemNotFoundSugg::Similar {
span: assoc_name.span, span: assoc_ident.span,
assoc_kind: assoc_kind_str, assoc_kind: assoc_kind_str,
suggested_name, suggested_name,
}); });
@ -201,7 +205,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.collect(); .collect();
if let Some(suggested_name) = if let Some(suggested_name) =
find_best_match_for_name(&wider_candidate_names, assoc_name.name, None) find_best_match_for_name(&wider_candidate_names, assoc_ident.name, None)
{ {
if let [best_trait] = visible_traits if let [best_trait] = visible_traits
.iter() .iter()
@ -215,11 +219,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
{ {
let trait_name = tcx.def_path_str(best_trait); let trait_name = tcx.def_path_str(best_trait);
err.label = Some(errors::AssocItemNotFoundLabel::FoundInOtherTrait { err.label = Some(errors::AssocItemNotFoundLabel::FoundInOtherTrait {
span: assoc_name.span, span: assoc_ident.span,
assoc_kind: assoc_kind_str, assoc_kind: assoc_kind_str,
trait_name: &trait_name, trait_name: &trait_name,
suggested_name, suggested_name,
identically_named: suggested_name == assoc_name.name, identically_named: suggested_name == assoc_ident.name,
}); });
if let AssocItemQSelf::TyParam(ty_param_def_id, ty_param_span) = qself if let AssocItemQSelf::TyParam(ty_param_def_id, ty_param_span) = qself
// Not using `self.item_def_id()` here as that would yield the opaque type itself if we're // Not using `self.item_def_id()` here as that would yield the opaque type itself if we're
@ -246,7 +250,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// The type param already has a bound for `trait_name`, we just need to // The type param already has a bound for `trait_name`, we just need to
// change the associated item. // change the associated item.
err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTrait { err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTrait {
span: assoc_name.span, span: assoc_ident.span,
assoc_kind: assoc_kind_str, assoc_kind: assoc_kind_str,
suggested_name, suggested_name,
}); });
@ -265,7 +269,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
Applicability::MaybeIncorrect Applicability::MaybeIncorrect
}; };
let identically_named = suggested_name == assoc_name.name; let identically_named = suggested_name == assoc_ident.name;
if let DefKind::TyAlias = tcx.def_kind(item_def_id) if let DefKind::TyAlias = tcx.def_kind(item_def_id)
&& !tcx.type_alias_is_lazy(item_def_id) && !tcx.type_alias_is_lazy(item_def_id)
@ -273,7 +277,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTraitQPath { err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTraitQPath {
lo: ty_param_span.shrink_to_lo(), lo: ty_param_span.shrink_to_lo(),
mi: ty_param_span.shrink_to_hi(), mi: ty_param_span.shrink_to_hi(),
hi: (!identically_named).then_some(assoc_name.span), hi: (!identically_named).then_some(assoc_ident.span),
trait_ref, trait_ref,
identically_named, identically_named,
suggested_name, suggested_name,
@ -294,7 +298,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// We suggested constraining a type parameter, but the associated item on it // We suggested constraining a type parameter, but the associated item on it
// was also not an exact match, so we also suggest changing it. // was also not an exact match, so we also suggest changing it.
err.span_suggestion_verbose( err.span_suggestion_verbose(
assoc_name.span, assoc_ident.span,
fluent::hir_analysis_assoc_item_not_found_similar_in_other_trait_with_bound_sugg, fluent::hir_analysis_assoc_item_not_found_similar_in_other_trait_with_bound_sugg,
suggested_name, suggested_name,
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
@ -311,13 +315,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// suggest using it. // suggest using it.
if let [candidate_name] = all_candidate_names.as_slice() { if let [candidate_name] = all_candidate_names.as_slice() {
err.sugg = Some(errors::AssocItemNotFoundSugg::Other { err.sugg = Some(errors::AssocItemNotFoundSugg::Other {
span: assoc_name.span, span: assoc_ident.span,
qself: &qself_str, qself: &qself_str,
assoc_kind: assoc_kind_str, assoc_kind: assoc_kind_str,
suggested_name: *candidate_name, suggested_name: *candidate_name,
}); });
} else { } else {
err.label = Some(errors::AssocItemNotFoundLabel::NotFound { span: assoc_name.span }); err.label = Some(errors::AssocItemNotFoundLabel::NotFound { span: assoc_ident.span });
} }
self.dcx().emit_err(err) self.dcx().emit_err(err)
@ -805,7 +809,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
return None; return None;
}; };
let assoc_item = tcx.associated_items(trait_def).find_by_name_and_kind( let assoc_item = tcx.associated_items(trait_def).find_by_ident_and_kind(
tcx, tcx,
ident, ident,
ty::AssocKind::Type, ty::AssocKind::Type,

View File

@ -147,7 +147,7 @@ pub trait HirTyLowerer<'tcx> {
&self, &self,
span: Span, span: Span,
def_id: LocalDefId, def_id: LocalDefId,
assoc_name: Ident, assoc_ident: Ident,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]>; ) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]>;
/// Lower an associated type/const (from a trait) to a projection. /// Lower an associated type/const (from a trait) to a projection.
@ -933,11 +933,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self, &self,
trait_def_id: DefId, trait_def_id: DefId,
assoc_kind: ty::AssocKind, assoc_kind: ty::AssocKind,
assoc_name: Ident, assoc_ident: Ident,
) -> bool { ) -> bool {
self.tcx() self.tcx()
.associated_items(trait_def_id) .associated_items(trait_def_id)
.find_by_name_and_kind(self.tcx(), assoc_name, assoc_kind, trait_def_id) .find_by_ident_and_kind(self.tcx(), assoc_ident, assoc_kind, trait_def_id)
.is_some() .is_some()
} }
@ -964,7 +964,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
} }
/// Search for a trait bound on a type parameter whose trait defines the associated item /// Search for a trait bound on a type parameter whose trait defines the associated item
/// given by `assoc_name` and `kind`. /// given by `assoc_ident` and `kind`.
/// ///
/// This fails if there is no such bound in the list of candidates or if there are multiple /// This fails if there is no such bound in the list of candidates or if there are multiple
/// candidates in which case it reports ambiguity. /// candidates in which case it reports ambiguity.
@ -976,13 +976,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
ty_param_def_id: LocalDefId, ty_param_def_id: LocalDefId,
ty_param_span: Span, ty_param_span: Span,
kind: ty::AssocKind, kind: ty::AssocKind,
assoc_name: Ident, assoc_ident: Ident,
span: Span, span: Span,
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> { ) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> {
debug!(?ty_param_def_id, ?assoc_name, ?span); debug!(?ty_param_def_id, ?assoc_ident, ?span);
let tcx = self.tcx(); let tcx = self.tcx();
let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_name); let predicates = &self.probe_ty_param_bounds(span, ty_param_def_id, assoc_ident);
debug!("predicates={:#?}", predicates); debug!("predicates={:#?}", predicates);
self.probe_single_bound_for_assoc_item( self.probe_single_bound_for_assoc_item(
@ -990,17 +990,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let trait_refs = predicates let trait_refs = predicates
.iter_identity_copied() .iter_identity_copied()
.filter_map(|(p, _)| Some(p.as_trait_clause()?.map_bound(|t| t.trait_ref))); .filter_map(|(p, _)| Some(p.as_trait_clause()?.map_bound(|t| t.trait_ref)));
traits::transitive_bounds_that_define_assoc_item(tcx, trait_refs, assoc_name) traits::transitive_bounds_that_define_assoc_item(tcx, trait_refs, assoc_ident)
}, },
AssocItemQSelf::TyParam(ty_param_def_id, ty_param_span), AssocItemQSelf::TyParam(ty_param_def_id, ty_param_span),
kind, kind,
assoc_name, assoc_ident,
span, span,
None, None,
) )
} }
/// Search for a single trait bound whose trait defines the associated item given by `assoc_name`. /// Search for a single trait bound whose trait defines the associated item given by
/// `assoc_ident`.
/// ///
/// This fails if there is no such bound in the list of candidates or if there are multiple /// This fails if there is no such bound in the list of candidates or if there are multiple
/// candidates in which case it reports ambiguity. /// candidates in which case it reports ambiguity.
@ -1010,7 +1011,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
all_candidates: impl Fn() -> I, all_candidates: impl Fn() -> I,
qself: AssocItemQSelf, qself: AssocItemQSelf,
assoc_kind: ty::AssocKind, assoc_kind: ty::AssocKind,
assoc_name: Ident, assoc_ident: Ident,
span: Span, span: Span,
constraint: Option<&hir::AssocItemConstraint<'tcx>>, constraint: Option<&hir::AssocItemConstraint<'tcx>>,
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed> ) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed>
@ -1020,7 +1021,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let tcx = self.tcx(); let tcx = self.tcx();
let mut matching_candidates = all_candidates().filter(|r| { let mut matching_candidates = all_candidates().filter(|r| {
self.probe_trait_that_defines_assoc_item(r.def_id(), assoc_kind, assoc_name) self.probe_trait_that_defines_assoc_item(r.def_id(), assoc_kind, assoc_ident)
}); });
let Some(bound) = matching_candidates.next() else { let Some(bound) = matching_candidates.next() else {
@ -1028,7 +1029,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
all_candidates, all_candidates,
qself, qself,
assoc_kind, assoc_kind,
assoc_name, assoc_ident,
span, span,
constraint, constraint,
); );
@ -1044,7 +1045,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let mut err = self.dcx().create_err(crate::errors::AmbiguousAssocItem { let mut err = self.dcx().create_err(crate::errors::AmbiguousAssocItem {
span, span,
assoc_kind: assoc_kind_str, assoc_kind: assoc_kind_str,
assoc_name, assoc_ident,
qself: &qself_str, qself: &qself_str,
}); });
// Provide a more specific error code index entry for equality bindings. // Provide a more specific error code index entry for equality bindings.
@ -1065,13 +1066,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let bound_id = bound.def_id(); let bound_id = bound.def_id();
let bound_span = tcx let bound_span = tcx
.associated_items(bound_id) .associated_items(bound_id)
.find_by_name_and_kind(tcx, assoc_name, assoc_kind, bound_id) .find_by_ident_and_kind(tcx, assoc_ident, assoc_kind, bound_id)
.and_then(|item| tcx.hir_span_if_local(item.def_id)); .and_then(|item| tcx.hir_span_if_local(item.def_id));
if let Some(bound_span) = bound_span { if let Some(bound_span) = bound_span {
err.span_label( err.span_label(
bound_span, bound_span,
format!("ambiguous `{assoc_name}` from `{}`", bound.print_trait_sugared(),), format!("ambiguous `{assoc_ident}` from `{}`", bound.print_trait_sugared(),),
); );
if let Some(constraint) = constraint { if let Some(constraint) = constraint {
match constraint.kind { match constraint.kind {
@ -1087,7 +1088,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
} }
// FIXME(#97583): This isn't syntactically well-formed! // FIXME(#97583): This isn't syntactically well-formed!
where_bounds.push(format!( where_bounds.push(format!(
" T: {trait}::{assoc_name} = {term}", " T: {trait}::{assoc_ident} = {term}",
trait = bound.print_only_trait_path(), trait = bound.print_only_trait_path(),
)); ));
} }
@ -1096,7 +1097,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
} }
} else { } else {
err.span_suggestion_verbose( err.span_suggestion_verbose(
span.with_hi(assoc_name.span.lo()), span.with_hi(assoc_ident.span.lo()),
"use fully-qualified syntax to disambiguate", "use fully-qualified syntax to disambiguate",
format!("<{qself_str} as {}>::", bound.print_only_trait_path()), format!("<{qself_str} as {}>::", bound.print_only_trait_path()),
Applicability::MaybeIncorrect, Applicability::MaybeIncorrect,
@ -1104,7 +1105,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
} }
} else { } else {
err.note(format!( err.note(format!(
"associated {assoc_kind_str} `{assoc_name}` could derive from `{}`", "associated {assoc_kind_str} `{assoc_ident}` could derive from `{}`",
bound.print_only_trait_path(), bound.print_only_trait_path(),
)); ));
} }
@ -2858,7 +2859,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let trait_ref = self.lower_impl_trait_ref(i.of_trait.as_ref()?, self.lower_ty(i.self_ty)); let trait_ref = self.lower_impl_trait_ref(i.of_trait.as_ref()?, self.lower_ty(i.self_ty));
let assoc = tcx.associated_items(trait_ref.def_id).find_by_name_and_kind( let assoc = tcx.associated_items(trait_ref.def_id).find_by_ident_and_kind(
tcx, tcx,
*ident, *ident,
ty::AssocKind::Fn, ty::AssocKind::Fn,

View File

@ -397,7 +397,7 @@ impl<'a> State<'a> {
self.pclose(); self.pclose();
} }
hir::TyKind::BareFn(f) => { hir::TyKind::BareFn(f) => {
self.print_ty_fn(f.abi, f.safety, f.decl, None, f.generic_params, f.param_names); self.print_ty_fn(f.abi, f.safety, f.decl, None, f.generic_params, f.param_idents);
} }
hir::TyKind::UnsafeBinder(unsafe_binder) => { hir::TyKind::UnsafeBinder(unsafe_binder) => {
self.print_unsafe_binder(unsafe_binder); self.print_unsafe_binder(unsafe_binder);
@ -473,14 +473,14 @@ impl<'a> State<'a> {
self.maybe_print_comment(item.span.lo()); self.maybe_print_comment(item.span.lo());
self.print_attrs_as_outer(self.attrs(item.hir_id())); self.print_attrs_as_outer(self.attrs(item.hir_id()));
match item.kind { match item.kind {
hir::ForeignItemKind::Fn(sig, arg_names, generics) => { hir::ForeignItemKind::Fn(sig, arg_idents, generics) => {
self.head(""); self.head("");
self.print_fn( self.print_fn(
sig.decl, sig.decl,
sig.header, sig.header,
Some(item.ident.name), Some(item.ident.name),
generics, generics,
arg_names, arg_idents,
None, None,
); );
self.end(); // end head-ibox self.end(); // end head-ibox
@ -899,10 +899,10 @@ impl<'a> State<'a> {
ident: Ident, ident: Ident,
m: &hir::FnSig<'_>, m: &hir::FnSig<'_>,
generics: &hir::Generics<'_>, generics: &hir::Generics<'_>,
arg_names: &[Option<Ident>], arg_idents: &[Option<Ident>],
body_id: Option<hir::BodyId>, body_id: Option<hir::BodyId>,
) { ) {
self.print_fn(m.decl, m.header, Some(ident.name), generics, arg_names, body_id); self.print_fn(m.decl, m.header, Some(ident.name), generics, arg_idents, body_id);
} }
fn print_trait_item(&mut self, ti: &hir::TraitItem<'_>) { fn print_trait_item(&mut self, ti: &hir::TraitItem<'_>) {
@ -914,8 +914,8 @@ impl<'a> State<'a> {
hir::TraitItemKind::Const(ty, default) => { hir::TraitItemKind::Const(ty, default) => {
self.print_associated_const(ti.ident, ti.generics, ty, default); self.print_associated_const(ti.ident, ti.generics, ty, default);
} }
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(arg_names)) => { hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(arg_idents)) => {
self.print_method_sig(ti.ident, sig, ti.generics, arg_names, None); self.print_method_sig(ti.ident, sig, ti.generics, arg_idents, None);
self.word(";"); self.word(";");
} }
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => { hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Provided(body)) => {
@ -2122,7 +2122,7 @@ impl<'a> State<'a> {
header: hir::FnHeader, header: hir::FnHeader,
name: Option<Symbol>, name: Option<Symbol>,
generics: &hir::Generics<'_>, generics: &hir::Generics<'_>,
arg_names: &[Option<Ident>], arg_idents: &[Option<Ident>],
body_id: Option<hir::BodyId>, body_id: Option<hir::BodyId>,
) { ) {
self.print_fn_header_info(header); self.print_fn_header_info(header);
@ -2134,16 +2134,16 @@ impl<'a> State<'a> {
self.print_generic_params(generics.params); self.print_generic_params(generics.params);
self.popen(); self.popen();
// Make sure we aren't supplied *both* `arg_names` and `body_id`. // Make sure we aren't supplied *both* `arg_idents` and `body_id`.
assert!(arg_names.is_empty() || body_id.is_none()); assert!(arg_idents.is_empty() || body_id.is_none());
let mut i = 0; let mut i = 0;
let mut print_arg = |s: &mut Self, ty: Option<&hir::Ty<'_>>| { let mut print_arg = |s: &mut Self, ty: Option<&hir::Ty<'_>>| {
if i == 0 && decl.implicit_self.has_implicit_self() { if i == 0 && decl.implicit_self.has_implicit_self() {
s.print_implicit_self(&decl.implicit_self); s.print_implicit_self(&decl.implicit_self);
} else { } else {
if let Some(arg_name) = arg_names.get(i) { if let Some(arg_ident) = arg_idents.get(i) {
if let Some(arg_name) = arg_name { if let Some(arg_ident) = arg_ident {
s.word(arg_name.to_string()); s.word(arg_ident.to_string());
s.word(":"); s.word(":");
s.space(); s.space();
} }
@ -2452,7 +2452,7 @@ impl<'a> State<'a> {
decl: &hir::FnDecl<'_>, decl: &hir::FnDecl<'_>,
name: Option<Symbol>, name: Option<Symbol>,
generic_params: &[hir::GenericParam<'_>], generic_params: &[hir::GenericParam<'_>],
arg_names: &[Option<Ident>], arg_idents: &[Option<Ident>],
) { ) {
self.ibox(INDENT_UNIT); self.ibox(INDENT_UNIT);
self.print_formal_generic_params(generic_params); self.print_formal_generic_params(generic_params);
@ -2467,7 +2467,7 @@ impl<'a> State<'a> {
}, },
name, name,
generics, generics,
arg_names, arg_idents,
None, None,
); );
self.end(); self.end();

View File

@ -148,7 +148,7 @@ hir_typeck_never_type_fallback_flowing_into_unsafe_path = never type fallback af
hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access hir_typeck_never_type_fallback_flowing_into_unsafe_union_field = never type fallback affects this union access
.help = specify the type explicitly .help = specify the type explicitly
hir_typeck_no_associated_item = no {$item_kind} named `{$item_name}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method -> hir_typeck_no_associated_item = no {$item_kind} named `{$item_ident}` found for {$ty_prefix} `{$ty_str}`{$trait_missing_method ->
[true] {""} [true] {""}
*[other] {" "}in the current scope *[other] {" "}in the current scope
} }

View File

@ -727,7 +727,7 @@ pub(crate) struct NoAssociatedItem {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub item_kind: &'static str, pub item_kind: &'static str,
pub item_name: Ident, pub item_ident: Ident,
pub ty_prefix: Cow<'static, str>, pub ty_prefix: Cow<'static, str>,
pub ty_str: String, pub ty_str: String,
pub trait_missing_method: bool, pub trait_missing_method: bool,

View File

@ -1136,7 +1136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& let self_implicit = && let self_implicit =
matches!(call_expr.kind, hir::ExprKind::MethodCall(..)) as usize matches!(call_expr.kind, hir::ExprKind::MethodCall(..)) as usize
&& let Some(Some(arg)) = && let Some(Some(arg)) =
self.tcx.fn_arg_names(fn_def_id).get(expected_idx.as_usize() + self_implicit) self.tcx.fn_arg_idents(fn_def_id).get(expected_idx.as_usize() + self_implicit)
&& arg.name != kw::SelfLower && arg.name != kw::SelfLower
{ {
format!("/* {} */", arg.name) format!("/* {} */", arg.name)
@ -2619,7 +2619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
is_method: bool, is_method: bool,
) -> Option<(IndexVec<ExpectedIdx, (Option<GenericIdx>, FnParam<'_>)>, &hir::Generics<'_>)> ) -> Option<(IndexVec<ExpectedIdx, (Option<GenericIdx>, FnParam<'_>)>, &hir::Generics<'_>)>
{ {
let (sig, generics, body_id, param_names) = match self.tcx.hir_get_if_local(def_id)? { let (sig, generics, body_id, params) = match self.tcx.hir_get_if_local(def_id)? {
hir::Node::TraitItem(&hir::TraitItem { hir::Node::TraitItem(&hir::TraitItem {
generics, generics,
kind: hir::TraitItemKind::Fn(sig, trait_fn), kind: hir::TraitItemKind::Fn(sig, trait_fn),
@ -2661,7 +2661,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None None
} }
}); });
match (body_id, param_names) { match (body_id, params) {
(Some(_), Some(_)) | (None, None) => unreachable!(), (Some(_), Some(_)) | (None, None) => unreachable!(),
(Some(body), None) => { (Some(body), None) => {
let params = self.tcx.hir_body(body).params; let params = self.tcx.hir_body(body).params;
@ -2678,7 +2678,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
params.get(is_method as usize..params.len() - sig.decl.c_variadic as usize)?; params.get(is_method as usize..params.len() - sig.decl.c_variadic as usize)?;
debug_assert_eq!(params.len(), fn_inputs.len()); debug_assert_eq!(params.len(), fn_inputs.len());
Some(( Some((
fn_inputs.zip(params.iter().map(|&ident| FnParam::Name(ident))).collect(), fn_inputs.zip(params.iter().map(|&ident| FnParam::Ident(ident))).collect(),
generics, generics,
)) ))
} }
@ -2709,14 +2709,14 @@ impl<'tcx> Visitor<'tcx> for FindClosureArg<'tcx> {
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
enum FnParam<'hir> { enum FnParam<'hir> {
Param(&'hir hir::Param<'hir>), Param(&'hir hir::Param<'hir>),
Name(Option<Ident>), Ident(Option<Ident>),
} }
impl FnParam<'_> { impl FnParam<'_> {
fn span(&self) -> Span { fn span(&self) -> Span {
match self { match self {
Self::Param(param) => param.span, Self::Param(param) => param.span,
Self::Name(ident) => { Self::Ident(ident) => {
if let Some(ident) = ident { if let Some(ident) = ident {
ident.span ident.span
} else { } else {
@ -2738,7 +2738,7 @@ impl FnParam<'_> {
{ {
Some(ident.name) Some(ident.name)
} }
FnParam::Name(ident) FnParam::Ident(ident)
if let Some(ident) = ident if let Some(ident) = ident
&& ident.name != kw::Underscore => && ident.name != kw::Underscore =>
{ {

View File

@ -534,12 +534,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Ok((def_kind, pick.item.def_id)) Ok((def_kind, pick.item.def_id))
} }
/// Finds item with name `item_name` defined in impl/trait `def_id` /// Finds item with name `item_ident` defined in impl/trait `def_id`
/// and return it, or `None`, if no such item was defined there. /// and return it, or `None`, if no such item was defined there.
fn associated_value(&self, def_id: DefId, item_name: Ident) -> Option<ty::AssocItem> { fn associated_value(&self, def_id: DefId, item_ident: Ident) -> Option<ty::AssocItem> {
self.tcx self.tcx
.associated_items(def_id) .associated_items(def_id)
.find_by_name_and_namespace(self.tcx, item_name, Namespace::ValueNS, def_id) .find_by_ident_and_namespace(self.tcx, item_ident, Namespace::ValueNS, def_id)
.copied() .copied()
} }
} }

View File

@ -584,7 +584,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self, &self,
mut span: Span, mut span: Span,
rcvr_ty: Ty<'tcx>, rcvr_ty: Ty<'tcx>,
item_name: Ident, item_ident: Ident,
expr_id: hir::HirId, expr_id: hir::HirId,
source: SelfSource<'tcx>, source: SelfSource<'tcx>,
args: Option<&'tcx [hir::Expr<'tcx>]>, args: Option<&'tcx [hir::Expr<'tcx>]>,
@ -615,7 +615,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if rcvr_ty.is_enum() { } else if rcvr_ty.is_enum() {
"variant or associated item" "variant or associated item"
} else { } else {
match (item_name.as_str().chars().next(), rcvr_ty.is_fresh_ty()) { match (item_ident.as_str().chars().next(), rcvr_ty.is_fresh_ty()) {
(Some(name), false) if name.is_lowercase() => "function or associated item", (Some(name), false) if name.is_lowercase() => "function or associated item",
(Some(_), false) => "associated item", (Some(_), false) => "associated item",
(Some(_), true) | (None, false) => "variant or associated item", (Some(_), true) | (None, false) => "variant or associated item",
@ -630,7 +630,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
rcvr_ty, rcvr_ty,
source, source,
span, span,
item_name, item_ident,
&short_ty_str, &short_ty_str,
&mut ty_file, &mut ty_file,
) { ) {
@ -642,13 +642,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source, source,
span, span,
item_kind, item_kind,
item_name, item_ident,
&short_ty_str, &short_ty_str,
&mut ty_file, &mut ty_file,
) { ) {
return guar; return guar;
} }
span = item_name.span; span = item_ident.span;
// Don't show generic arguments when the method can't be found in any implementation (#81576). // Don't show generic arguments when the method can't be found in any implementation (#81576).
let mut ty_str_reported = ty_str.clone(); let mut ty_str_reported = ty_str.clone();
@ -660,7 +660,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx self.tcx
.inherent_impls(adt_def.did()) .inherent_impls(adt_def.did())
.into_iter() .into_iter()
.any(|def_id| self.associated_value(*def_id, item_name).is_some()) .any(|def_id| self.associated_value(*def_id, item_ident).is_some())
} else { } else {
false false
} }
@ -677,14 +677,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let is_write = sugg_span.ctxt().outer_expn_data().macro_def_id.is_some_and(|def_id| { let is_write = sugg_span.ctxt().outer_expn_data().macro_def_id.is_some_and(|def_id| {
tcx.is_diagnostic_item(sym::write_macro, def_id) tcx.is_diagnostic_item(sym::write_macro, def_id)
|| tcx.is_diagnostic_item(sym::writeln_macro, def_id) || tcx.is_diagnostic_item(sym::writeln_macro, def_id)
}) && item_name.name == sym::write_fmt; }) && item_ident.name == sym::write_fmt;
let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source { let mut err = if is_write && let SelfSource::MethodCall(rcvr_expr) = source {
self.suggest_missing_writer(rcvr_ty, rcvr_expr) self.suggest_missing_writer(rcvr_ty, rcvr_expr)
} else { } else {
let mut err = self.dcx().create_err(NoAssociatedItem { let mut err = self.dcx().create_err(NoAssociatedItem {
span, span,
item_kind, item_kind,
item_name, item_ident,
ty_prefix: if trait_missing_method { ty_prefix: if trait_missing_method {
// FIXME(mu001999) E0599 maybe not suitable here because it is for types // FIXME(mu001999) E0599 maybe not suitable here because it is for types
Cow::from("trait") Cow::from("trait")
@ -698,7 +698,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if is_method { if is_method {
self.suggest_use_shadowed_binding_with_method( self.suggest_use_shadowed_binding_with_method(
source, source,
item_name, item_ident,
&ty_str_reported, &ty_str_reported,
&mut err, &mut err,
); );
@ -709,9 +709,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind && let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind
&& let Res::SelfTyAlias { alias_to: impl_def_id, .. } = path.res && let Res::SelfTyAlias { alias_to: impl_def_id, .. } = path.res
&& let DefKind::Impl { .. } = self.tcx.def_kind(impl_def_id) && let DefKind::Impl { .. } = self.tcx.def_kind(impl_def_id)
&& let Some(candidate) = tcx.associated_items(impl_def_id).find_by_name_and_kind( && let Some(candidate) = tcx.associated_items(impl_def_id).find_by_ident_and_kind(
self.tcx, self.tcx,
item_name, item_ident,
ty::AssocKind::Type, ty::AssocKind::Type,
impl_def_id, impl_def_id,
) )
@ -721,7 +721,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{ {
let def_path = tcx.def_path_str(adt_def.did()); let def_path = tcx.def_path_str(adt_def.did());
err.span_suggestion( err.span_suggestion(
ty.span.to(item_name.span), ty.span.to(item_ident.span),
format!("to construct a value of type `{}`, use the explicit path", def_path), format!("to construct a value of type `{}`, use the explicit path", def_path),
def_path, def_path,
Applicability::MachineApplicable, Applicability::MachineApplicable,
@ -749,7 +749,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.find_builder_fn(&mut err, rcvr_ty, expr_id); self.find_builder_fn(&mut err, rcvr_ty, expr_id);
} }
if tcx.ty_is_opaque_future(rcvr_ty) && item_name.name == sym::poll { if tcx.ty_is_opaque_future(rcvr_ty) && item_ident.name == sym::poll {
err.help(format!( err.help(format!(
"method `poll` found on `Pin<&mut {ty_str}>`, \ "method `poll` found on `Pin<&mut {ty_str}>`, \
see documentation for `std::pin::Pin`" see documentation for `std::pin::Pin`"
@ -764,7 +764,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{ {
self.suggest_await_before_method( self.suggest_await_before_method(
&mut err, &mut err,
item_name, item_ident,
rcvr_ty, rcvr_ty,
cal, cal,
span, span,
@ -786,7 +786,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let SelfSource::MethodCall(rcvr_expr) = source if let SelfSource::MethodCall(rcvr_expr) = source
&& let ty::RawPtr(ty, ptr_mutbl) = *rcvr_ty.kind() && let ty::RawPtr(ty, ptr_mutbl) = *rcvr_ty.kind()
&& let Ok(pick) = self.lookup_probe_for_diagnostic( && let Ok(pick) = self.lookup_probe_for_diagnostic(
item_name, item_ident,
Ty::new_ref(tcx, ty::Region::new_error_misc(tcx), ty, ptr_mutbl), Ty::new_ref(tcx, ty::Region::new_error_misc(tcx), ty, ptr_mutbl),
self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id)), self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id)),
ProbeScope::TraitsInScope, ProbeScope::TraitsInScope,
@ -807,7 +807,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}; };
err.span_note( err.span_note(
tcx.def_span(pick.item.def_id), tcx.def_span(pick.item.def_id),
format!("the method `{item_name}` exists on the type `{ty}`", ty = pick.self_ty), format!("the method `{item_ident}` exists on the type `{ty}`", ty = pick.self_ty),
); );
let mut_str = ptr_mutbl.ptr_str(); let mut_str = ptr_mutbl.ptr_str();
err.note(format!( err.note(format!(
@ -833,7 +833,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.suggest_fn_call(&mut err, rcvr_expr, rcvr_ty, |output_ty| { self.suggest_fn_call(&mut err, rcvr_expr, rcvr_ty, |output_ty| {
let call_expr = self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id)); let call_expr = self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id));
let probe = self.lookup_probe_for_diagnostic( let probe = self.lookup_probe_for_diagnostic(
item_name, item_ident,
output_ty, output_ty,
call_expr, call_expr,
ProbeScope::AllTraits, ProbeScope::AllTraits,
@ -872,13 +872,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
static_candidates, static_candidates,
rcvr_ty, rcvr_ty,
source, source,
item_name, item_ident,
args, args,
sugg_span, sugg_span,
); );
self.note_candidates_on_method_error( self.note_candidates_on_method_error(
rcvr_ty, rcvr_ty,
item_name, item_ident,
source, source,
args, args,
span, span,
@ -889,7 +889,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if static_candidates.len() > 1 { } else if static_candidates.len() > 1 {
self.note_candidates_on_method_error( self.note_candidates_on_method_error(
rcvr_ty, rcvr_ty,
item_name, item_ident,
source, source,
args, args,
span, span,
@ -903,7 +903,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut restrict_type_params = false; let mut restrict_type_params = false;
let mut suggested_derive = false; let mut suggested_derive = false;
let mut unsatisfied_bounds = false; let mut unsatisfied_bounds = false;
if item_name.name == sym::count && self.is_slice_ty(rcvr_ty, span) { if item_ident.name == sym::count && self.is_slice_ty(rcvr_ty, span) {
let msg = "consider using `len` instead"; let msg = "consider using `len` instead";
if let SelfSource::MethodCall(_expr) = source { if let SelfSource::MethodCall(_expr) = source {
err.span_suggestion_short(span, msg, "len", Applicability::MachineApplicable); err.span_suggestion_short(span, msg, "len", Applicability::MachineApplicable);
@ -1348,7 +1348,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}; };
let primary_message = primary_message.unwrap_or_else(|| { let primary_message = primary_message.unwrap_or_else(|| {
format!( format!(
"the {item_kind} `{item_name}` exists for {actual_prefix} `{ty_str}`, \ "the {item_kind} `{item_ident}` exists for {actual_prefix} `{ty_str}`, \
but its trait bounds were not satisfied" but its trait bounds were not satisfied"
) )
}); });
@ -1378,7 +1378,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// `Pin<&Self>`. // `Pin<&Self>`.
if targs.len() == 1 { if targs.len() == 1 {
let mut item_segment = hir::PathSegment::invalid(); let mut item_segment = hir::PathSegment::invalid();
item_segment.ident = item_name; item_segment.ident = item_ident;
for t in [Ty::new_mut_ref, Ty::new_imm_ref, |_, _, t| t] { for t in [Ty::new_mut_ref, Ty::new_imm_ref, |_, _, t| t] {
let new_args = let new_args =
tcx.mk_args_from_iter(targs.iter().map(|arg| match arg.as_type() { tcx.mk_args_from_iter(targs.iter().map(|arg| match arg.as_type() {
@ -1422,9 +1422,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::Adt(adt, _) => self.tcx.is_lang_item(adt.did(), LangItem::String), ty::Adt(adt, _) => self.tcx.is_lang_item(adt.did(), LangItem::String),
_ => false, _ => false,
}; };
if is_string_or_ref_str && item_name.name == sym::iter { if is_string_or_ref_str && item_ident.name == sym::iter {
err.span_suggestion_verbose( err.span_suggestion_verbose(
item_name.span, item_ident.span,
"because of the in-memory representation of `&str`, to obtain \ "because of the in-memory representation of `&str`, to obtain \
an `Iterator` over each of its codepoint use method `chars`", an `Iterator` over each of its codepoint use method `chars`",
"chars", "chars",
@ -1438,7 +1438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.into_iter() .into_iter()
.copied() .copied()
.filter(|def_id| { .filter(|def_id| {
if let Some(assoc) = self.associated_value(*def_id, item_name) { if let Some(assoc) = self.associated_value(*def_id, item_ident) {
// Check for both mode is the same so we avoid suggesting // Check for both mode is the same so we avoid suggesting
// incorrect associated item. // incorrect associated item.
match (mode, assoc.fn_has_self_parameter, source) { match (mode, assoc.fn_has_self_parameter, source) {
@ -1499,7 +1499,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// If the method name is the name of a field with a function or closure type, // If the method name is the name of a field with a function or closure type,
// give a helping note that it has to be called as `(x.f)(...)`. // give a helping note that it has to be called as `(x.f)(...)`.
if let SelfSource::MethodCall(expr) = source { if let SelfSource::MethodCall(expr) = source {
if !self.suggest_calling_field_as_fn(span, rcvr_ty, expr, item_name, &mut err) if !self.suggest_calling_field_as_fn(span, rcvr_ty, expr, item_ident, &mut err)
&& similar_candidate.is_none() && similar_candidate.is_none()
&& !custom_span_label && !custom_span_label
{ {
@ -1512,7 +1512,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let confusable_suggested = self.confusable_method_name( let confusable_suggested = self.confusable_method_name(
&mut err, &mut err,
rcvr_ty, rcvr_ty,
item_name, item_ident,
args.map(|args| { args.map(|args| {
args.iter() args.iter()
.map(|expr| { .map(|expr| {
@ -1530,12 +1530,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source, source,
span, span,
rcvr_ty, rcvr_ty,
item_name, item_ident,
expected.only_has_type(self), expected.only_has_type(self),
); );
} }
self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name); self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_ident);
for (span, mut bounds) in bound_spans { for (span, mut bounds) in bound_spans {
if !tcx.sess.source_map().is_span_accessible(span) { if !tcx.sess.source_map().is_span_accessible(span) {
@ -1546,7 +1546,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let pre = if Some(span) == ty_span { let pre = if Some(span) == ty_span {
ty_span.take(); ty_span.take();
format!( format!(
"{item_kind} `{item_name}` not found for this {} because it ", "{item_kind} `{item_ident}` not found for this {} because it ",
rcvr_ty.prefix_string(self.tcx) rcvr_ty.prefix_string(self.tcx)
) )
} else { } else {
@ -1566,7 +1566,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label( err.span_label(
span, span,
format!( format!(
"{item_kind} `{item_name}` not found for this {}", "{item_kind} `{item_ident}` not found for this {}",
rcvr_ty.prefix_string(self.tcx) rcvr_ty.prefix_string(self.tcx)
), ),
); );
@ -1578,7 +1578,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&mut err, &mut err,
span, span,
rcvr_ty, rcvr_ty,
item_name, item_ident,
args.map(|args| args.len() + 1), args.map(|args| args.len() + 1),
source, source,
no_match_data.out_of_scope_traits.clone(), no_match_data.out_of_scope_traits.clone(),
@ -1595,7 +1595,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let adt_def = rcvr_ty.ty_adt_def().expect("enum is not an ADT"); let adt_def = rcvr_ty.ty_adt_def().expect("enum is not an ADT");
if let Some(var_name) = edit_distance::find_best_match_for_name( if let Some(var_name) = edit_distance::find_best_match_for_name(
&adt_def.variants().iter().map(|s| s.name).collect::<Vec<_>>(), &adt_def.variants().iter().map(|s| s.name).collect::<Vec<_>>(),
item_name.name, item_ident.name,
None, None,
) && let Some(variant) = adt_def.variants().iter().find(|s| s.name == var_name) ) && let Some(variant) = adt_def.variants().iter().find(|s| s.name == var_name)
{ {
@ -1736,14 +1736,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !find_candidate_for_method { if !find_candidate_for_method {
self.lookup_segments_chain_for_no_match_method( self.lookup_segments_chain_for_no_match_method(
&mut err, &mut err,
item_name, item_ident,
item_kind, item_kind,
source, source,
no_match_data, no_match_data,
); );
} }
self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_name, expected); self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_ident, expected);
err.emit() err.emit()
} }

View File

@ -859,7 +859,7 @@ impl<'tcx> LateContext<'tcx> {
) -> Option<Ty<'tcx>> { ) -> Option<Ty<'tcx>> {
let tcx = self.tcx; let tcx = self.tcx;
tcx.associated_items(trait_id) tcx.associated_items(trait_id)
.find_by_name_and_kind(tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id) .find_by_ident_and_kind(tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id)
.and_then(|assoc| { .and_then(|assoc| {
let proj = Ty::new_projection(tcx, assoc.def_id, [self_ty]); let proj = Ty::new_projection(tcx, assoc.def_id, [self_ty]);
tcx.try_normalize_erasing_regions(self.typing_env(), proj).ok() tcx.try_normalize_erasing_regions(self.typing_env(), proj).ok()

View File

@ -423,11 +423,11 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
} }
fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &hir::TraitItem<'_>) { fn check_trait_item(&mut self, cx: &LateContext<'_>, item: &hir::TraitItem<'_>) {
if let hir::TraitItemKind::Fn(_, hir::TraitFn::Required(pnames)) = item.kind { if let hir::TraitItemKind::Fn(_, hir::TraitFn::Required(param_idents)) = item.kind {
self.check_snake_case(cx, "trait method", &item.ident); self.check_snake_case(cx, "trait method", &item.ident);
for param_name in pnames { for param_ident in param_idents {
if let Some(param_name) = param_name { if let Some(param_ident) = param_ident {
self.check_snake_case(cx, "variable", param_name); self.check_snake_case(cx, "variable", param_ident);
} }
} }
} }

View File

@ -1313,7 +1313,7 @@ impl<'a> CrateMetadataRef<'a> {
fn get_fn_has_self_parameter(self, id: DefIndex, sess: &'a Session) -> bool { fn get_fn_has_self_parameter(self, id: DefIndex, sess: &'a Session) -> bool {
self.root self.root
.tables .tables
.fn_arg_names .fn_arg_idents
.get(self, id) .get(self, id)
.expect("argument names not encoded for a function") .expect("argument names not encoded for a function")
.decode((self, sess)) .decode((self, sess))

View File

@ -286,7 +286,7 @@ provide! { tcx, def_id, other, cdata,
rendered_const => { table } rendered_const => { table }
rendered_precise_capturing_args => { table } rendered_precise_capturing_args => { table }
asyncness => { table_direct } asyncness => { table_direct }
fn_arg_names => { table } fn_arg_idents => { table }
coroutine_kind => { table_direct } coroutine_kind => { table_direct }
coroutine_for_closure => { table } coroutine_for_closure => { table }
coroutine_by_move_body_def_id => { table } coroutine_by_move_body_def_id => { table }

View File

@ -1469,7 +1469,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
} }
if let DefKind::Fn | DefKind::AssocFn = def_kind { if let DefKind::Fn | DefKind::AssocFn = def_kind {
self.tables.asyncness.set_some(def_id.index, tcx.asyncness(def_id)); self.tables.asyncness.set_some(def_id.index, tcx.asyncness(def_id));
record_array!(self.tables.fn_arg_names[def_id] <- tcx.fn_arg_names(def_id)); record_array!(self.tables.fn_arg_idents[def_id] <- tcx.fn_arg_idents(def_id));
} }
if let Some(name) = tcx.intrinsic(def_id) { if let Some(name) = tcx.intrinsic(def_id) {
record!(self.tables.intrinsic[def_id] <- name); record!(self.tables.intrinsic[def_id] <- name);

View File

@ -451,7 +451,7 @@ define_tables! {
rendered_const: Table<DefIndex, LazyValue<String>>, rendered_const: Table<DefIndex, LazyValue<String>>,
rendered_precise_capturing_args: Table<DefIndex, LazyArray<PreciseCapturingArgKind<Symbol, Symbol>>>, rendered_precise_capturing_args: Table<DefIndex, LazyArray<PreciseCapturingArgKind<Symbol, Symbol>>>,
asyncness: Table<DefIndex, ty::Asyncness>, asyncness: Table<DefIndex, ty::Asyncness>,
fn_arg_names: Table<DefIndex, LazyArray<Option<Ident>>>, fn_arg_idents: Table<DefIndex, LazyArray<Option<Ident>>>,
coroutine_kind: Table<DefIndex, hir::CoroutineKind>, coroutine_kind: Table<DefIndex, hir::CoroutineKind>,
coroutine_for_closure: Table<DefIndex, RawDefId>, coroutine_for_closure: Table<DefIndex, RawDefId>,
adt_destructor: Table<DefIndex, LazyValue<ty::Destructor>>, adt_destructor: Table<DefIndex, LazyValue<ty::Destructor>>,

View File

@ -281,7 +281,7 @@ impl<'tcx> TyCtxt<'tcx> {
}) })
} }
pub fn hir_body_param_names(self, id: BodyId) -> impl Iterator<Item = Option<Ident>> { pub fn hir_body_param_idents(self, id: BodyId) -> impl Iterator<Item = Option<Ident>> {
self.hir_body(id).params.iter().map(|param| match param.pat.kind { self.hir_body(id).params.iter().map(|param| match param.pat.kind {
PatKind::Binding(_, _, ident, _) => Some(ident), PatKind::Binding(_, _, ident, _) => Some(ident),
PatKind::Wild => Some(Ident::new(kw::Underscore, param.pat.span)), PatKind::Wild => Some(Ident::new(kw::Underscore, param.pat.span)),

View File

@ -215,9 +215,9 @@ pub fn provide(providers: &mut Providers) {
let hir_id = tcx.local_def_id_to_hir_id(def_id); let hir_id = tcx.local_def_id_to_hir_id(def_id);
tcx.hir_opt_ident_span(hir_id) tcx.hir_opt_ident_span(hir_id)
}; };
providers.fn_arg_names = |tcx, def_id| { providers.fn_arg_idents = |tcx, def_id| {
if let Some(body_id) = tcx.hir_node_by_def_id(def_id).body_id() { if let Some(body_id) = tcx.hir_node_by_def_id(def_id).body_id() {
tcx.arena.alloc_from_iter(tcx.hir_body_param_names(body_id)) tcx.arena.alloc_from_iter(tcx.hir_body_param_idents(body_id))
} else if let Node::TraitItem(&TraitItem { } else if let Node::TraitItem(&TraitItem {
kind: TraitItemKind::Fn(_, TraitFn::Required(idents)), kind: TraitItemKind::Fn(_, TraitFn::Required(idents)),
.. ..
@ -231,7 +231,7 @@ pub fn provide(providers: &mut Providers) {
} else { } else {
span_bug!( span_bug!(
tcx.hir_span(tcx.local_def_id_to_hir_id(def_id)), tcx.hir_span(tcx.local_def_id_to_hir_id(def_id)),
"fn_arg_names: unexpected item {:?}", "fn_arg_idents: unexpected item {:?}",
def_id def_id
); );
} }

View File

@ -1435,8 +1435,8 @@ rustc_queries! {
desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) } desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
} }
query fn_arg_names(def_id: DefId) -> &'tcx [Option<rustc_span::Ident>] { query fn_arg_idents(def_id: DefId) -> &'tcx [Option<rustc_span::Ident>] {
desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) } desc { |tcx| "looking up function parameter idents for `{}`", tcx.def_path_str(def_id) }
separate_provide_extern separate_provide_extern
} }

View File

@ -199,8 +199,8 @@ impl AssocItems {
self.items.get_by_key(name) self.items.get_by_key(name)
} }
/// Returns the associated item with the given name and `AssocKind`, if one exists. /// Returns the associated item with the given ident and `AssocKind`, if one exists.
pub fn find_by_name_and_kind( pub fn find_by_ident_and_kind(
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
ident: Ident, ident: Ident,
@ -212,8 +212,8 @@ impl AssocItems {
.find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id)) .find(|item| tcx.hygienic_eq(ident, item.ident(tcx), parent_def_id))
} }
/// Returns the associated item with the given name and any of `AssocKind`, if one exists. /// Returns the associated item with the given ident and any of `AssocKind`, if one exists.
pub fn find_by_name_and_kinds( pub fn find_by_ident_and_kinds(
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
ident: Ident, ident: Ident,
@ -221,11 +221,11 @@ impl AssocItems {
kinds: &[AssocKind], kinds: &[AssocKind],
parent_def_id: DefId, parent_def_id: DefId,
) -> Option<&ty::AssocItem> { ) -> Option<&ty::AssocItem> {
kinds.iter().find_map(|kind| self.find_by_name_and_kind(tcx, ident, *kind, parent_def_id)) kinds.iter().find_map(|kind| self.find_by_ident_and_kind(tcx, ident, *kind, parent_def_id))
} }
/// Returns the associated item with the given name in the given `Namespace`, if one exists. /// Returns the associated item with the given ident in the given `Namespace`, if one exists.
pub fn find_by_name_and_namespace( pub fn find_by_ident_and_namespace(
&self, &self,
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
ident: Ident, ident: Ident,

View File

@ -1939,15 +1939,15 @@ impl<'tcx> TyCtxt<'tcx> {
/// Hygienically compares a use-site name (`use_name`) for a field or an associated item with /// Hygienically compares a use-site name (`use_name`) for a field or an associated item with
/// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed /// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed
/// definition's parent/scope to perform comparison. /// definition's parent/scope to perform comparison.
pub fn hygienic_eq(self, use_name: Ident, def_name: Ident, def_parent_def_id: DefId) -> bool { pub fn hygienic_eq(self, use_ident: Ident, def_ident: Ident, def_parent_def_id: DefId) -> bool {
// We could use `Ident::eq` here, but we deliberately don't. The name // We could use `Ident::eq` here, but we deliberately don't. The ident
// comparison fails frequently, and we want to avoid the expensive // comparison fails frequently, and we want to avoid the expensive
// `normalize_to_macros_2_0()` calls required for the span comparison whenever possible. // `normalize_to_macros_2_0()` calls required for the span comparison whenever possible.
use_name.name == def_name.name use_ident.name == def_ident.name
&& use_name && use_ident
.span .span
.ctxt() .ctxt()
.hygienic_eq(def_name.span.ctxt(), self.expn_that_defined(def_parent_def_id)) .hygienic_eq(def_ident.span.ctxt(), self.expn_that_defined(def_parent_def_id))
} }
pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident { pub fn adjust_ident(self, mut ident: Ident, scope: DefId) -> Ident {

View File

@ -174,7 +174,7 @@ impl<'tcx> MoveCheckVisitor<'tcx> {
fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option<DefId> { fn assoc_fn_of_type<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, fn_ident: Ident) -> Option<DefId> {
for impl_def_id in tcx.inherent_impls(def_id) { for impl_def_id in tcx.inherent_impls(def_id) {
if let Some(new) = tcx.associated_items(impl_def_id).find_by_name_and_kind( if let Some(new) = tcx.associated_items(impl_def_id).find_by_ident_and_kind(
tcx, tcx,
fn_ident, fn_ident,
AssocKind::Fn, AssocKind::Fn,

View File

@ -2550,7 +2550,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
.iter() .iter()
.filter_map(|item| { .filter_map(|item| {
let parent_module = self.opt_local_def_id(item.parent_module)?.to_def_id(); let parent_module = self.opt_local_def_id(item.parent_module)?.to_def_id();
Some(StrippedCfgItem { parent_module, name: item.name, cfg: item.cfg.clone() }) Some(StrippedCfgItem {
parent_module,
ident: item.ident,
cfg: item.cfg.clone(),
})
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
local_items.as_slice() local_items.as_slice()
@ -2558,12 +2562,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
self.tcx.stripped_cfg_items(module.krate) self.tcx.stripped_cfg_items(module.krate)
}; };
for &StrippedCfgItem { parent_module, name, ref cfg } in symbols { for &StrippedCfgItem { parent_module, ident, ref cfg } in symbols {
if parent_module != module || name.name != *segment { if parent_module != module || ident.name != *segment {
continue; continue;
} }
let note = errors::FoundItemConfigureOut { span: name.span }; let note = errors::FoundItemConfigureOut { span: ident.span };
err.subdiagnostic(note); err.subdiagnostic(note);
if let MetaItemKind::List(nested) = &cfg.kind if let MetaItemKind::List(nested) = &cfg.kind

View File

@ -2238,7 +2238,7 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
.get(&def_id) .get(&def_id)
.is_some_and(|sig| sig.has_self), .is_some_and(|sig| sig.has_self),
None => { None => {
self.r.tcx.fn_arg_names(def_id).first().is_some_and(|&ident| { self.r.tcx.fn_arg_idents(def_id).first().is_some_and(|&ident| {
matches!(ident, Some(Ident { name: kw::SelfLower, .. })) matches!(ident, Some(Ident { name: kw::SelfLower, .. }))
}) })
} }

View File

@ -1648,7 +1648,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
.filter_map(|item| { .filter_map(|item| {
let parent_module = let parent_module =
self.node_id_to_def_id.get(&item.parent_module)?.key().to_def_id(); self.node_id_to_def_id.get(&item.parent_module)?.key().to_def_id();
Some(StrippedCfgItem { parent_module, name: item.name, cfg: item.cfg }) Some(StrippedCfgItem { parent_module, ident: item.ident, cfg: item.cfg })
}) })
.collect(), .collect(),
); );

View File

@ -469,8 +469,8 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
self.proc_macros.push(id) self.proc_macros.push(id)
} }
fn append_stripped_cfg_item(&mut self, parent_node: NodeId, name: Ident, cfg: ast::MetaItem) { fn append_stripped_cfg_item(&mut self, parent_node: NodeId, ident: Ident, cfg: ast::MetaItem) {
self.stripped_cfg_items.push(StrippedCfgItem { parent_module: parent_node, name, cfg }); self.stripped_cfg_items.push(StrippedCfgItem { parent_module: parent_node, ident, cfg });
} }
fn registered_tools(&self) -> &RegisteredTools { fn registered_tools(&self) -> &RegisteredTools {

View File

@ -1988,7 +1988,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
{ {
let closure: Vec<_> = self let closure: Vec<_> = self
.tcx .tcx
.fn_arg_names(fn_def_id) .fn_arg_idents(fn_def_id)
.iter() .iter()
.enumerate() .enumerate()
.map(|(i, ident)| { .map(|(i, ident)| {
@ -5397,7 +5397,7 @@ fn point_at_assoc_type_restriction<G: EmissionGuarantee>(
); );
} }
if let Some(new) = if let Some(new) =
tcx.associated_items(data.impl_or_alias_def_id).find_by_name_and_kind( tcx.associated_items(data.impl_or_alias_def_id).find_by_ident_and_kind(
tcx, tcx,
Ident::with_dummy_span(name), Ident::with_dummy_span(name),
ty::AssocKind::Type, ty::AssocKind::Type,

View File

@ -497,7 +497,7 @@ pub(crate) fn build_impl(
}; };
let trait_item = tcx let trait_item = tcx
.associated_items(associated_trait.def_id) .associated_items(associated_trait.def_id)
.find_by_name_and_kind( .find_by_ident_and_kind(
tcx, tcx,
item.ident, item.ident,
assoc_kind, assoc_kind,
@ -524,7 +524,7 @@ pub(crate) fn build_impl(
if let Some(associated_trait) = associated_trait { if let Some(associated_trait) = associated_trait {
let trait_item = tcx let trait_item = tcx
.associated_items(associated_trait.def_id) .associated_items(associated_trait.def_id)
.find_by_name_and_kind( .find_by_ident_and_kind(
tcx, tcx,
item.ident(tcx), item.ident(tcx),
item.kind, item.kind,

View File

@ -1088,7 +1088,7 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[hir::Attrib
enum FunctionArgs<'tcx> { enum FunctionArgs<'tcx> {
Body(hir::BodyId), Body(hir::BodyId),
Names(&'tcx [Option<Ident>]), Idents(&'tcx [Option<Ident>]),
} }
fn clean_function<'tcx>( fn clean_function<'tcx>(
@ -1104,8 +1104,8 @@ fn clean_function<'tcx>(
FunctionArgs::Body(body_id) => { FunctionArgs::Body(body_id) => {
clean_args_from_types_and_body_id(cx, sig.decl.inputs, body_id) clean_args_from_types_and_body_id(cx, sig.decl.inputs, body_id)
} }
FunctionArgs::Names(names) => { FunctionArgs::Idents(idents) => {
clean_args_from_types_and_names(cx, sig.decl.inputs, names) clean_args_from_types_and_names(cx, sig.decl.inputs, idents)
} }
}; };
let decl = clean_fn_decl_with_args(cx, sig.decl, Some(&sig.header), args); let decl = clean_fn_decl_with_args(cx, sig.decl, Some(&sig.header), args);
@ -1117,7 +1117,7 @@ fn clean_function<'tcx>(
fn clean_args_from_types_and_names<'tcx>( fn clean_args_from_types_and_names<'tcx>(
cx: &mut DocContext<'tcx>, cx: &mut DocContext<'tcx>,
types: &[hir::Ty<'tcx>], types: &[hir::Ty<'tcx>],
names: &[Option<Ident>], idents: &[Option<Ident>],
) -> Arguments { ) -> Arguments {
fn nonempty_name(ident: &Option<Ident>) -> Option<Symbol> { fn nonempty_name(ident: &Option<Ident>) -> Option<Symbol> {
if let Some(ident) = ident if let Some(ident) = ident
@ -1131,7 +1131,7 @@ fn clean_args_from_types_and_names<'tcx>(
// If at least one argument has a name, use `_` as the name of unnamed // If at least one argument has a name, use `_` as the name of unnamed
// arguments. Otherwise omit argument names. // arguments. Otherwise omit argument names.
let default_name = if names.iter().any(|ident| nonempty_name(ident).is_some()) { let default_name = if idents.iter().any(|ident| nonempty_name(ident).is_some()) {
kw::Underscore kw::Underscore
} else { } else {
kw::Empty kw::Empty
@ -1143,7 +1143,7 @@ fn clean_args_from_types_and_names<'tcx>(
.enumerate() .enumerate()
.map(|(i, ty)| Argument { .map(|(i, ty)| Argument {
type_: clean_ty(ty, cx), type_: clean_ty(ty, cx),
name: names.get(i).and_then(nonempty_name).unwrap_or(default_name), name: idents.get(i).and_then(nonempty_name).unwrap_or(default_name),
is_const: false, is_const: false,
}) })
.collect(), .collect(),
@ -1193,7 +1193,7 @@ fn clean_poly_fn_sig<'tcx>(
did: Option<DefId>, did: Option<DefId>,
sig: ty::PolyFnSig<'tcx>, sig: ty::PolyFnSig<'tcx>,
) -> FnDecl { ) -> FnDecl {
let mut names = did.map_or(&[] as &[_], |did| cx.tcx.fn_arg_names(did)).iter(); let mut names = did.map_or(&[] as &[_], |did| cx.tcx.fn_arg_idents(did)).iter();
// We assume all empty tuples are default return type. This theoretically can discard `-> ()`, // We assume all empty tuples are default return type. This theoretically can discard `-> ()`,
// but shouldn't change any code meaning. // but shouldn't change any code meaning.
@ -1270,8 +1270,8 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Body(body)); let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Body(body));
MethodItem(m, None) MethodItem(m, None)
} }
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => { hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(idents)) => {
let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Names(names)); let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Idents(idents));
RequiredMethodItem(m) RequiredMethodItem(m)
} }
hir::TraitItemKind::Type(bounds, Some(default)) => { hir::TraitItemKind::Type(bounds, Some(default)) => {
@ -2612,7 +2612,7 @@ fn clean_bare_fn_ty<'tcx>(
.filter(|p| !is_elided_lifetime(p)) .filter(|p| !is_elided_lifetime(p))
.map(|x| clean_generic_param(cx, None, x)) .map(|x| clean_generic_param(cx, None, x))
.collect(); .collect();
let args = clean_args_from_types_and_names(cx, bare_fn.decl.inputs, bare_fn.param_names); let args = clean_args_from_types_and_names(cx, bare_fn.decl.inputs, bare_fn.param_idents);
let decl = clean_fn_decl_with_args(cx, bare_fn.decl, None, args); let decl = clean_fn_decl_with_args(cx, bare_fn.decl, None, args);
(generic_params, decl) (generic_params, decl)
}); });
@ -3148,8 +3148,8 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
let def_id = item.owner_id.to_def_id(); let def_id = item.owner_id.to_def_id();
cx.with_param_env(def_id, |cx| { cx.with_param_env(def_id, |cx| {
let kind = match item.kind { let kind = match item.kind {
hir::ForeignItemKind::Fn(sig, names, generics) => ForeignFunctionItem( hir::ForeignItemKind::Fn(sig, idents, generics) => ForeignFunctionItem(
clean_function(cx, &sig, generics, FunctionArgs::Names(names)), clean_function(cx, &sig, generics, FunctionArgs::Idents(idents)),
sig.header.safety(), sig.header.safety(),
), ),
hir::ForeignItemKind::Static(ty, mutability, safety) => ForeignStaticItem( hir::ForeignItemKind::Static(ty, mutability, safety) => ForeignStaticItem(

View File

@ -53,7 +53,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
.not_trait() .not_trait()
.filter(|trait_id| implements_trait(cx, ty, *trait_id, &[])) .filter(|trait_id| implements_trait(cx, ty, *trait_id, &[]))
.and_then(|trait_id| { .and_then(|trait_id| {
cx.tcx.associated_items(trait_id).find_by_name_and_kind( cx.tcx.associated_items(trait_id).find_by_ident_and_kind(
cx.tcx, cx.tcx,
Ident::from_str("Output"), Ident::from_str("Output"),
ty::AssocKind::Type, ty::AssocKind::Type,

View File

@ -22,8 +22,8 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, item: &ImplItem<'_>, ignored
&& let Some(did) = trait_item_def_id_of_impl(items, item.owner_id) && let Some(did) = trait_item_def_id_of_impl(items, item.owner_id)
&& !is_from_ignored_trait(trait_ref, ignored_traits) && !is_from_ignored_trait(trait_ref, ignored_traits)
{ {
let mut param_idents_iter = cx.tcx.hir_body_param_names(body_id); let mut param_idents_iter = cx.tcx.hir_body_param_idents(body_id);
let mut default_param_idents_iter = cx.tcx.fn_arg_names(did).iter().copied(); let mut default_param_idents_iter = cx.tcx.fn_arg_idents(did).iter().copied();
let renames = RenamedFnArgs::new(&mut default_param_idents_iter, &mut param_idents_iter); let renames = RenamedFnArgs::new(&mut default_param_idents_iter, &mut param_idents_iter);
if !renames.0.is_empty() { if !renames.0.is_empty() {

View File

@ -238,7 +238,7 @@ fn is_contains_sig(cx: &LateContext<'_>, call_id: HirId, iter_expr: &Expr<'_>) -
.instantiate_bound_regions_with_erased(sig.rebind(search_ty)) .instantiate_bound_regions_with_erased(sig.rebind(search_ty))
.kind() .kind()
&& let Some(iter_trait) = cx.tcx.get_diagnostic_item(sym::Iterator) && let Some(iter_trait) = cx.tcx.get_diagnostic_item(sym::Iterator)
&& let Some(iter_item) = cx.tcx.associated_items(iter_trait).find_by_name_and_kind( && let Some(iter_item) = cx.tcx.associated_items(iter_trait).find_by_ident_and_kind(
cx.tcx, cx.tcx,
Ident::with_dummy_span(sym::Item), Ident::with_dummy_span(sym::Item),
AssocKind::Type, AssocKind::Type,

View File

@ -1109,7 +1109,7 @@ pub fn make_projection<'tcx>(
assoc_ty: Symbol, assoc_ty: Symbol,
args: GenericArgsRef<'tcx>, args: GenericArgsRef<'tcx>,
) -> Option<AliasTy<'tcx>> { ) -> Option<AliasTy<'tcx>> {
let Some(assoc_item) = tcx.associated_items(container_id).find_by_name_and_kind( let Some(assoc_item) = tcx.associated_items(container_id).find_by_ident_and_kind(
tcx, tcx,
Ident::with_dummy_span(assoc_ty), Ident::with_dummy_span(assoc_ty),
AssocKind::Type, AssocKind::Type,

View File

@ -3,7 +3,7 @@
extern crate foreign_trait_with_assoc; extern crate foreign_trait_with_assoc;
use foreign_trait_with_assoc::Foo; use foreign_trait_with_assoc::Foo;
// Make sure we don't try to call `fn_arg_names` on a non-fn item. // Make sure we don't try to call `fn_arg_idents` on a non-fn item.
impl Foo for Bar {} impl Foo for Bar {}
//~^ ERROR cannot find type `Bar` in this scope //~^ ERROR cannot find type `Bar` in this scope