Rollup merge of #139510 - nnethercote:name-to-ident, r=fee1-dead

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.

r? `@fee1-dead`
This commit is contained in:
Matthias Krüger 2025-04-10 17:27:14 +02:00 committed by GitHub
commit 79f357e63d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
52 changed files with 241 additions and 229 deletions

View File

@ -13,12 +13,12 @@ pub mod typetree;
#[derive(Debug, Clone, Encodable, Decodable, HashStable_Generic)]
pub struct StrippedCfgItem<ModId = DefId> {
pub parent_module: ModId,
pub name: Ident,
pub ident: Ident,
pub cfg: MetaItem,
}
impl<ModId> StrippedCfgItem<ModId> {
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.
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
// 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(
generics,
sig,
@ -851,7 +851,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
(
*ident,
generics,
hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(names)),
hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(idents)),
false,
)
}

View File

@ -1247,7 +1247,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
safety: self.lower_safety(f.safety, hir::Safety::Safe),
abi: self.lower_extern(f.ext),
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) => {
@ -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 {
PatKind::Missing => None,
PatKind::Ident(_, ident, _) => Some(self.lower_ident(ident)),

View File

@ -7,12 +7,12 @@ use super::*;
fn fun_to_string(
decl: &ast::FnDecl,
header: ast::FnHeader,
name: Ident,
ident: Ident,
generics: &ast::Generics,
) -> String {
to_string(|s| {
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 outer box.
})

View File

@ -2500,11 +2500,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
);
let ty::Tuple(params) = tupled_params.kind() else { return };
// Find the first argument with a matching type, get its name
let Some(this_name) = params.iter().zip(tcx.hir_body_param_names(closure.body)).find_map(
|(param_ty, name)| {
// Find the first argument with a matching type and get its identifier.
let Some(this_name) = params.iter().zip(tcx.hir_body_param_idents(closure.body)).find_map(
|(param_ty, ident)| {
// 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 {
return;
@ -3774,7 +3774,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
method_args,
*fn_span,
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}`"));

View File

@ -1026,7 +1026,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
method_args,
*fn_span,
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 {

View File

@ -20,14 +20,14 @@ use crate::errors;
struct ProcMacroDerive {
id: NodeId,
trait_name: Symbol,
function_name: Ident,
function_ident: Ident,
span: Span,
attrs: Vec<Symbol>,
}
struct ProcMacroDef {
id: NodeId,
function_name: Ident,
function_ident: Ident,
span: Span,
}
@ -95,7 +95,7 @@ impl<'a> CollectProcMacros<'a> {
fn collect_custom_derive(
&mut self,
item: &'a ast::Item,
function_name: Ident,
function_ident: Ident,
attr: &'a ast::Attribute,
) {
let Some((trait_name, proc_attrs)) =
@ -109,7 +109,7 @@ impl<'a> CollectProcMacros<'a> {
id: item.id,
span: item.span,
trait_name,
function_name,
function_ident,
attrs: proc_attrs,
}));
} 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() {
self.macros.push(ProcMacro::Attr(ProcMacroDef {
id: item.id,
span: item.span,
function_name,
function_ident,
}));
} else {
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() {
self.macros.push(ProcMacro::Bang(ProcMacroDef {
id: item.id,
span: item.span,
function_name,
function_ident,
}));
} else {
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::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| {
cx.expr_path(cx.path(
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))
.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,
proc_macro_ty_method_path(cx, ident),
thin_vec![
cx.expr_str(span, ca.function_name.name),
local_path(cx, ca.function_name),
cx.expr_str(span, ca.function_ident.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 report = tcx
.associated_items(termination_trait)
.find_by_name_and_kind(
.find_by_ident_and_kind(
tcx,
Ident::from_str("report"),
AssocKind::Fn,

View File

@ -1102,7 +1102,7 @@ pub trait ResolverExpand {
/// HIR proc macros items back to their harness items.
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.
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() });
}
/// All of the names (items) declared by this node.
/// All of the identifiers (items) declared by this node.
/// This is an approximation and should only be used for diagnostics.
fn declared_names(&self) -> Vec<Ident> {
fn declared_idents(&self) -> Vec<Ident> {
vec![]
}
}
@ -1306,7 +1306,7 @@ impl InvocationCollectorNode for P<ast::Item> {
res
}
fn declared_names(&self) -> Vec<Ident> {
fn declared_idents(&self) -> Vec<Ident> {
if let ItemKind::Use(ut) = &self.kind {
fn collect_use_tree_leaves(ut: &ast::UseTree, idents: &mut Vec<Ident>) {
match &ut.kind {
@ -2061,10 +2061,10 @@ impl<'a, 'b> InvocationCollector<'a, 'b> {
}
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.current_expansion.lint_node_id,
name,
ident,
meta_item.clone(),
)
}

View File

@ -3399,9 +3399,9 @@ pub struct BareFnTy<'hir> {
pub abi: ExternAbi,
pub generic_params: &'hir [GenericParam<'hir>],
pub decl: &'hir FnDecl<'hir>,
// `Option` because bare fn parameter names are optional. We also end up
// `Option` because bare fn parameter identifiers are optional. We also end up
// 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)]

View File

@ -652,10 +652,10 @@ pub fn walk_foreign_item<'v, V: Visitor<'v>>(
try_visit!(visitor.visit_ident(foreign_item.ident));
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_fn_decl(sig.decl));
for ident in param_names.iter().copied() {
for ident in param_idents.iter().copied() {
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));
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));
for ident in param_names.iter().copied() {
for ident in param_idents.iter().copied() {
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}`
.label = ambiguous associated {$assoc_kind} `{$assoc_name}`
hir_analysis_ambiguous_assoc_item = ambiguous associated {$assoc_kind} `{$assoc_ident}` in bounds of `{$qself}`
.label = ambiguous associated {$assoc_kind} `{$assoc_ident}`
hir_analysis_ambiguous_lifetime_bound =
ambiguous lifetime bound, explicit lifetime bound required
@ -12,13 +12,13 @@ hir_analysis_assoc_item_is_private = {$kind} `{$name}` is private
.label = private {$kind}
.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 ->
[true] an
*[false] a similarly named
} 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_similar_in_other_trait_qpath_sugg =
consider fully qualifying{$identically_named ->

View File

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

View File

@ -439,9 +439,9 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
&self,
span: Span,
def_id: LocalDefId,
assoc_name: Ident,
assoc_ident: Ident,
) -> 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(

View File

@ -584,12 +584,12 @@ pub(super) fn explicit_super_predicates_of<'tcx>(
pub(super) fn explicit_supertraits_containing_assoc_item<'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)]> {
implied_predicates_with_filter(
tcx,
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,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
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
assert_matches!(filter, PredicateFilter::SelfTraitThatDefines(_));
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))]
pub(super) fn type_param_predicates<'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)]> {
match tcx.opt_rpitit_info(item_def_id.to_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 { .. }) => {
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 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 {
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(
hir_generics,
def_id,
PredicateFilter::SelfTraitThatDefines(assoc_name),
PredicateFilter::SelfTraitThatDefines(assoc_ident),
));
let bounds =
@ -908,7 +908,7 @@ pub(super) fn type_param_predicates<'tcx>(
_ => unreachable!(),
};
assert_only_contains_predicates_from(
PredicateFilter::SelfTraitThatDefines(assoc_name),
PredicateFilter::SelfTraitThatDefines(assoc_ident),
bounds,
self_ty,
);

View File

@ -1874,13 +1874,13 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
fn supertrait_hrtb_vars(
tcx: TyCtxt<'tcx>,
def_id: DefId,
assoc_name: Ident,
assoc_ident: Ident,
assoc_kind: ty::AssocKind,
) -> Option<(Vec<ty::BoundVariableKind>, &'tcx ty::AssocItem)> {
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,
assoc_name,
assoc_ident,
assoc_kind,
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) {
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 bound_predicate = pred.kind();
match bound_predicate.skip_binder() {

View File

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

View File

@ -363,10 +363,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
for hir_bound in hir_bounds {
// In order to avoid cycles, when we're lowering `SelfTraitThatDefines`,
// 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()
&& 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
} else {

View File

@ -49,13 +49,13 @@ pub(crate) fn validate_cmse_abi<'tcx>(
Ok(Err(index)) => {
// 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)
} else {
bare_fn_ty.decl.inputs[index].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 });
}
Err(layout_err) => {

View File

@ -117,7 +117,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
all_candidates: impl Fn() -> I,
qself: AssocItemQSelf,
assoc_kind: ty::AssocKind,
assoc_name: Ident,
assoc_ident: Ident,
span: Span,
constraint: Option<&hir::AssocItemConstraint<'tcx>>,
) -> ErrorGuaranteed
@ -129,11 +129,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// First and foremost, provide a more user-friendly & “intuitive” error on kind mismatches.
if let Some(assoc_item) = all_candidates().find_map(|r| {
tcx.associated_items(r.def_id())
.filter_by_name_unhygienic(assoc_name.name)
.find(|item| tcx.hygienic_eq(assoc_name, item.ident(tcx), r.def_id()))
.filter_by_name_unhygienic(assoc_ident.name)
.find(|item| tcx.hygienic_eq(assoc_ident, item.ident(tcx), r.def_id()))
}) {
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
// 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 {
span: if is_dummy { span } else { assoc_name.span },
assoc_name,
span: if is_dummy { span } else { assoc_ident.span },
assoc_ident,
assoc_kind: assoc_kind_str,
qself: &qself_str,
label: None,
sugg: None,
// Try to get the span of the identifier within the path's syntax context
// (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 {
@ -169,10 +173,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.collect();
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 {
span: assoc_name.span,
span: assoc_ident.span,
assoc_kind: assoc_kind_str,
suggested_name,
});
@ -201,7 +205,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.collect();
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
.iter()
@ -215,11 +219,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
{
let trait_name = tcx.def_path_str(best_trait);
err.label = Some(errors::AssocItemNotFoundLabel::FoundInOtherTrait {
span: assoc_name.span,
span: assoc_ident.span,
assoc_kind: assoc_kind_str,
trait_name: &trait_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
// 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
// change the associated item.
err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTrait {
span: assoc_name.span,
span: assoc_ident.span,
assoc_kind: assoc_kind_str,
suggested_name,
});
@ -265,7 +269,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
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)
&& !tcx.type_alias_is_lazy(item_def_id)
@ -273,7 +277,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
err.sugg = Some(errors::AssocItemNotFoundSugg::SimilarInOtherTraitQPath {
lo: ty_param_span.shrink_to_lo(),
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,
identically_named,
suggested_name,
@ -294,7 +298,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// We suggested constraining a type parameter, but the associated item on it
// was also not an exact match, so we also suggest changing it.
err.span_suggestion_verbose(
assoc_name.span,
assoc_ident.span,
fluent::hir_analysis_assoc_item_not_found_similar_in_other_trait_with_bound_sugg,
suggested_name,
Applicability::MaybeIncorrect,
@ -311,13 +315,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
// suggest using it.
if let [candidate_name] = all_candidate_names.as_slice() {
err.sugg = Some(errors::AssocItemNotFoundSugg::Other {
span: assoc_name.span,
span: assoc_ident.span,
qself: &qself_str,
assoc_kind: assoc_kind_str,
suggested_name: *candidate_name,
});
} 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)
@ -805,7 +809,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
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,
ident,
ty::AssocKind::Type,

View File

@ -147,7 +147,7 @@ pub trait HirTyLowerer<'tcx> {
&self,
span: Span,
def_id: LocalDefId,
assoc_name: Ident,
assoc_ident: Ident,
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]>;
/// Lower an associated type/const (from a trait) to a projection.
@ -933,11 +933,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
&self,
trait_def_id: DefId,
assoc_kind: ty::AssocKind,
assoc_name: Ident,
assoc_ident: Ident,
) -> bool {
self.tcx()
.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()
}
@ -964,7 +964,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
/// 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
/// candidates in which case it reports ambiguity.
@ -976,13 +976,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
ty_param_def_id: LocalDefId,
ty_param_span: Span,
kind: ty::AssocKind,
assoc_name: Ident,
assoc_ident: Ident,
span: Span,
) -> 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 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);
self.probe_single_bound_for_assoc_item(
@ -990,17 +990,18 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let trait_refs = predicates
.iter_identity_copied()
.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),
kind,
assoc_name,
assoc_ident,
span,
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
/// candidates in which case it reports ambiguity.
@ -1010,7 +1011,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
all_candidates: impl Fn() -> I,
qself: AssocItemQSelf,
assoc_kind: ty::AssocKind,
assoc_name: Ident,
assoc_ident: Ident,
span: Span,
constraint: Option<&hir::AssocItemConstraint<'tcx>>,
) -> Result<ty::PolyTraitRef<'tcx>, ErrorGuaranteed>
@ -1020,7 +1021,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let tcx = self.tcx();
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 {
@ -1028,7 +1029,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
all_candidates,
qself,
assoc_kind,
assoc_name,
assoc_ident,
span,
constraint,
);
@ -1044,7 +1045,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let mut err = self.dcx().create_err(crate::errors::AmbiguousAssocItem {
span,
assoc_kind: assoc_kind_str,
assoc_name,
assoc_ident,
qself: &qself_str,
});
// 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_span = tcx
.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));
if let Some(bound_span) = bound_span {
err.span_label(
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 {
match constraint.kind {
@ -1087,7 +1088,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
// FIXME(#97583): This isn't syntactically well-formed!
where_bounds.push(format!(
" T: {trait}::{assoc_name} = {term}",
" T: {trait}::{assoc_ident} = {term}",
trait = bound.print_only_trait_path(),
));
}
@ -1096,7 +1097,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
} else {
err.span_suggestion_verbose(
span.with_hi(assoc_name.span.lo()),
span.with_hi(assoc_ident.span.lo()),
"use fully-qualified syntax to disambiguate",
format!("<{qself_str} as {}>::", bound.print_only_trait_path()),
Applicability::MaybeIncorrect,
@ -1104,7 +1105,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
} else {
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(),
));
}
@ -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 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,
*ident,
ty::AssocKind::Fn,

View File

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

View File

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

View File

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

View File

@ -534,12 +534,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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.
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
.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()
}
}

View File

@ -585,7 +585,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&self,
mut span: Span,
rcvr_ty: Ty<'tcx>,
item_name: Ident,
item_ident: Ident,
expr_id: hir::HirId,
source: SelfSource<'tcx>,
args: Option<&'tcx [hir::Expr<'tcx>]>,
@ -616,7 +616,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if rcvr_ty.is_enum() {
"variant or associated item"
} 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(_), false) => "associated item",
(Some(_), true) | (None, false) => "variant or associated item",
@ -631,7 +631,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
rcvr_ty,
source,
span,
item_name,
item_ident,
&short_ty_str,
&mut ty_file,
) {
@ -643,13 +643,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source,
span,
item_kind,
item_name,
item_ident,
&short_ty_str,
&mut ty_file,
) {
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).
let mut ty_str_reported = ty_str.clone();
@ -661,7 +661,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.tcx
.inherent_impls(adt_def.did())
.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 {
false
}
@ -678,14 +678,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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::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 {
self.suggest_missing_writer(rcvr_ty, rcvr_expr)
} else {
let mut err = self.dcx().create_err(NoAssociatedItem {
span,
item_kind,
item_name,
item_ident,
ty_prefix: if trait_missing_method {
// FIXME(mu001999) E0599 maybe not suitable here because it is for types
Cow::from("trait")
@ -699,7 +699,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if is_method {
self.suggest_use_shadowed_binding_with_method(
source,
item_name,
item_ident,
&ty_str_reported,
&mut err,
);
@ -710,9 +710,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind
&& let Res::SelfTyAlias { alias_to: impl_def_id, .. } = path.res
&& 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,
item_name,
item_ident,
ty::AssocKind::Type,
impl_def_id,
)
@ -722,7 +722,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
let def_path = tcx.def_path_str(adt_def.did());
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),
def_path,
Applicability::MachineApplicable,
@ -750,7 +750,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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!(
"method `poll` found on `Pin<&mut {ty_str}>`, \
see documentation for `std::pin::Pin`"
@ -765,7 +765,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{
self.suggest_await_before_method(
&mut err,
item_name,
item_ident,
rcvr_ty,
cal,
span,
@ -787,7 +787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let SelfSource::MethodCall(rcvr_expr) = source
&& let ty::RawPtr(ty, ptr_mutbl) = *rcvr_ty.kind()
&& 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),
self.tcx.hir_expect_expr(self.tcx.parent_hir_id(rcvr_expr.hir_id)),
ProbeScope::TraitsInScope,
@ -808,7 +808,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
err.span_note(
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();
err.note(format!(
@ -834,7 +834,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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 probe = self.lookup_probe_for_diagnostic(
item_name,
item_ident,
output_ty,
call_expr,
ProbeScope::AllTraits,
@ -873,13 +873,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
static_candidates,
rcvr_ty,
source,
item_name,
item_ident,
args,
sugg_span,
);
self.note_candidates_on_method_error(
rcvr_ty,
item_name,
item_ident,
source,
args,
span,
@ -890,7 +890,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if static_candidates.len() > 1 {
self.note_candidates_on_method_error(
rcvr_ty,
item_name,
item_ident,
source,
args,
span,
@ -904,7 +904,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut restrict_type_params = false;
let mut suggested_derive = 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";
if let SelfSource::MethodCall(_expr) = source {
err.span_suggestion_short(span, msg, "len", Applicability::MachineApplicable);
@ -1349,7 +1349,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};
let primary_message = primary_message.unwrap_or_else(|| {
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"
)
});
@ -1379,7 +1379,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// `Pin<&Self>`.
if targs.len() == 1 {
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] {
let new_args =
tcx.mk_args_from_iter(targs.iter().map(|arg| match arg.as_type() {
@ -1423,9 +1423,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
ty::Adt(adt, _) => self.tcx.is_lang_item(adt.did(), LangItem::String),
_ => 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(
item_name.span,
item_ident.span,
"because of the in-memory representation of `&str`, to obtain \
an `Iterator` over each of its codepoint use method `chars`",
"chars",
@ -1439,7 +1439,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.into_iter()
.copied()
.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
// incorrect associated item.
match (mode, assoc.fn_has_self_parameter, source) {
@ -1500,7 +1500,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// 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)(...)`.
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()
&& !custom_span_label
{
@ -1513,7 +1513,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let confusable_suggested = self.confusable_method_name(
&mut err,
rcvr_ty,
item_name,
item_ident,
args.map(|args| {
args.iter()
.map(|expr| {
@ -1531,12 +1531,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
source,
span,
rcvr_ty,
item_name,
item_ident,
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 {
if !tcx.sess.source_map().is_span_accessible(span) {
@ -1547,7 +1547,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let pre = if Some(span) == ty_span {
ty_span.take();
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)
)
} else {
@ -1567,7 +1567,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(
span,
format!(
"{item_kind} `{item_name}` not found for this {}",
"{item_kind} `{item_ident}` not found for this {}",
rcvr_ty.prefix_string(self.tcx)
),
);
@ -1579,7 +1579,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&mut err,
span,
rcvr_ty,
item_name,
item_ident,
args.map(|args| args.len() + 1),
source,
no_match_data.out_of_scope_traits.clone(),
@ -1596,7 +1596,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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(
&adt_def.variants().iter().map(|s| s.name).collect::<Vec<_>>(),
item_name.name,
item_ident.name,
None,
) && let Some(variant) = adt_def.variants().iter().find(|s| s.name == var_name)
{
@ -1737,14 +1737,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if !find_candidate_for_method {
self.lookup_segments_chain_for_no_match_method(
&mut err,
item_name,
item_ident,
item_kind,
source,
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()
}

View File

@ -859,7 +859,7 @@ impl<'tcx> LateContext<'tcx> {
) -> Option<Ty<'tcx>> {
let tcx = self.tcx;
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| {
let proj = Ty::new_projection(tcx, assoc.def_id, [self_ty]);
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<'_>) {
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);
for param_name in pnames {
if let Some(param_name) = param_name {
self.check_snake_case(cx, "variable", param_name);
for param_ident in param_idents {
if let Some(param_ident) = param_ident {
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 {
self.root
.tables
.fn_arg_names
.fn_arg_idents
.get(self, id)
.expect("argument names not encoded for a function")
.decode((self, sess))

View File

@ -286,7 +286,7 @@ provide! { tcx, def_id, other, cdata,
rendered_const => { table }
rendered_precise_capturing_args => { table }
asyncness => { table_direct }
fn_arg_names => { table }
fn_arg_idents => { table }
coroutine_kind => { table_direct }
coroutine_for_closure => { 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 {
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) {
record!(self.tables.intrinsic[def_id] <- name);

View File

@ -451,7 +451,7 @@ define_tables! {
rendered_const: Table<DefIndex, LazyValue<String>>,
rendered_precise_capturing_args: Table<DefIndex, LazyArray<PreciseCapturingArgKind<Symbol, Symbol>>>,
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_for_closure: Table<DefIndex, RawDefId>,
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 {
PatKind::Binding(_, _, ident, _) => Some(ident),
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);
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() {
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 {
kind: TraitItemKind::Fn(_, TraitFn::Required(idents)),
..
@ -231,7 +231,7 @@ pub fn provide(providers: &mut Providers) {
} else {
span_bug!(
tcx.hir_span(tcx.local_def_id_to_hir_id(def_id)),
"fn_arg_names: unexpected item {:?}",
"fn_arg_idents: unexpected item {:?}",
def_id
);
}

View File

@ -1442,8 +1442,8 @@ rustc_queries! {
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>] {
desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
query fn_arg_idents(def_id: DefId) -> &'tcx [Option<rustc_span::Ident>] {
desc { |tcx| "looking up function parameter identifiers for `{}`", tcx.def_path_str(def_id) }
separate_provide_extern
}

View File

@ -199,8 +199,9 @@ impl AssocItems {
self.items.get_by_key(name)
}
/// Returns the associated item with the given name and `AssocKind`, if one exists.
pub fn find_by_name_and_kind(
/// Returns the associated item with the given identifier and `AssocKind`, if one exists.
/// The identifier is matched hygienically.
pub fn find_by_ident_and_kind(
&self,
tcx: TyCtxt<'_>,
ident: Ident,
@ -212,8 +213,9 @@ impl AssocItems {
.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.
pub fn find_by_name_and_kinds(
/// Returns the associated item with the given identifier and any of `AssocKind`, if one
/// exists. The identifier is matched hygienically.
pub fn find_by_ident_and_kinds(
&self,
tcx: TyCtxt<'_>,
ident: Ident,
@ -221,11 +223,12 @@ impl AssocItems {
kinds: &[AssocKind],
parent_def_id: DefId,
) -> 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.
pub fn find_by_name_and_namespace(
/// Returns the associated item with the given identifier in the given `Namespace`, if one
/// exists. The identifier is matched hygienically.
pub fn find_by_ident_and_namespace(
&self,
tcx: TyCtxt<'_>,
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
/// its supposed definition name (`def_name`). The method also needs `DefId` of the supposed
/// definition's parent/scope to perform comparison.
pub fn hygienic_eq(self, use_name: Ident, def_name: Ident, def_parent_def_id: DefId) -> bool {
// We could use `Ident::eq` here, but we deliberately don't. The name
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 identifier
// comparison fails frequently, and we want to avoid the expensive
// `normalize_to_macros_2_0()` calls required for the span comparison whenever possible.
use_name.name == def_name.name
&& use_name
use_ident.name == def_ident.name
&& use_ident
.span
.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 {

View File

@ -191,7 +191,7 @@ impl<'tcx> MoveCheckVisitor<'tcx> {
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) {
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,
fn_ident,
AssocKind::Fn,

View File

@ -2550,7 +2550,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
.iter()
.filter_map(|item| {
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<_>>();
local_items.as_slice()
@ -2558,12 +2562,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
self.tcx.stripped_cfg_items(module.krate)
};
for &StrippedCfgItem { parent_module, name, ref cfg } in symbols {
if parent_module != module || name.name != *segment {
for &StrippedCfgItem { parent_module, ident, ref cfg } in symbols {
if parent_module != module || ident.name != *segment {
continue;
}
let note = errors::FoundItemConfigureOut { span: name.span };
let note = errors::FoundItemConfigureOut { span: ident.span };
err.subdiagnostic(note);
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)
.is_some_and(|sig| sig.has_self),
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, .. }))
})
}

View File

@ -1648,7 +1648,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
.filter_map(|item| {
let parent_module =
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(),
);

View File

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

View File

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

View File

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

View File

@ -1088,7 +1088,7 @@ fn clean_fn_decl_legacy_const_generics(func: &mut Function, attrs: &[hir::Attrib
enum FunctionArgs<'tcx> {
Body(hir::BodyId),
Names(&'tcx [Option<Ident>]),
Idents(&'tcx [Option<Ident>]),
}
fn clean_function<'tcx>(
@ -1104,8 +1104,8 @@ fn clean_function<'tcx>(
FunctionArgs::Body(body_id) => {
clean_args_from_types_and_body_id(cx, sig.decl.inputs, body_id)
}
FunctionArgs::Names(names) => {
clean_args_from_types_and_names(cx, sig.decl.inputs, names)
FunctionArgs::Idents(idents) => {
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);
@ -1117,7 +1117,7 @@ fn clean_function<'tcx>(
fn clean_args_from_types_and_names<'tcx>(
cx: &mut DocContext<'tcx>,
types: &[hir::Ty<'tcx>],
names: &[Option<Ident>],
idents: &[Option<Ident>],
) -> Arguments {
fn nonempty_name(ident: &Option<Ident>) -> Option<Symbol> {
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
// 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
} else {
kw::Empty
@ -1143,7 +1143,7 @@ fn clean_args_from_types_and_names<'tcx>(
.enumerate()
.map(|(i, ty)| Argument {
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,
})
.collect(),
@ -1193,7 +1193,7 @@ fn clean_poly_fn_sig<'tcx>(
did: Option<DefId>,
sig: ty::PolyFnSig<'tcx>,
) -> 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 `-> ()`,
// 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));
MethodItem(m, None)
}
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(names)) => {
let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Names(names));
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(idents)) => {
let m = clean_function(cx, sig, trait_item.generics, FunctionArgs::Idents(idents));
RequiredMethodItem(m)
}
hir::TraitItemKind::Type(bounds, Some(default)) => {
@ -2612,7 +2612,7 @@ fn clean_bare_fn_ty<'tcx>(
.filter(|p| !is_elided_lifetime(p))
.map(|x| clean_generic_param(cx, None, x))
.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);
(generic_params, decl)
});
@ -3148,8 +3148,8 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
let def_id = item.owner_id.to_def_id();
cx.with_param_env(def_id, |cx| {
let kind = match item.kind {
hir::ForeignItemKind::Fn(sig, names, generics) => ForeignFunctionItem(
clean_function(cx, &sig, generics, FunctionArgs::Names(names)),
hir::ForeignItemKind::Fn(sig, idents, generics) => ForeignFunctionItem(
clean_function(cx, &sig, generics, FunctionArgs::Idents(idents)),
sig.header.safety(),
),
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()
.filter(|trait_id| implements_trait(cx, ty, *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,
Ident::from_str("Output"),
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)
&& !is_from_ignored_trait(trait_ref, ignored_traits)
{
let mut param_idents_iter = cx.tcx.hir_body_param_names(body_id);
let mut default_param_idents_iter = cx.tcx.fn_arg_names(did).iter().copied();
let mut param_idents_iter = cx.tcx.hir_body_param_idents(body_id);
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);
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))
.kind()
&& 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,
Ident::with_dummy_span(sym::Item),
AssocKind::Type,

View File

@ -1109,7 +1109,7 @@ pub fn make_projection<'tcx>(
assoc_ty: Symbol,
args: GenericArgsRef<'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,
Ident::with_dummy_span(assoc_ty),
AssocKind::Type,

View File

@ -3,7 +3,7 @@
extern crate foreign_trait_with_assoc;
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 {}
//~^ ERROR cannot find type `Bar` in this scope