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:
commit
79f357e63d
52 changed files with 241 additions and 229 deletions
|
@ -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 ->
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue