Skip to content

Commit fef2f5b

Browse files
Rename things to reflect that they're not item specific
1 parent 20a8314 commit fef2f5b

File tree

8 files changed

+20
-25
lines changed

8 files changed

+20
-25
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10401040

10411041
/// Convert the bounds in `ast_bounds` that refer to traits which define an associated type
10421042
/// named `assoc_name` into ty::Bounds. Ignore the rest.
1043-
pub(crate) fn compute_bounds_that_match_assoc_type(
1043+
pub(crate) fn compute_bounds_that_match_assoc_item(
10441044
&self,
10451045
param_ty: Ty<'tcx>,
10461046
ast_bounds: &[hir::GenericBound<'_>],
@@ -1051,7 +1051,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10511051
for ast_bound in ast_bounds {
10521052
if let Some(trait_ref) = ast_bound.trait_ref()
10531053
&& let Some(trait_did) = trait_ref.trait_def_id()
1054-
&& self.tcx().trait_may_define_assoc_type(trait_did, assoc_name)
1054+
&& self.tcx().trait_may_define_assoc_item(trait_did, assoc_name)
10551055
{
10561056
result.push(ast_bound.clone());
10571057
}
@@ -1923,7 +1923,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19231923
let param_name = tcx.hir().ty_param_name(ty_param_def_id);
19241924
self.one_bound_for_assoc_type(
19251925
|| {
1926-
traits::transitive_bounds_that_define_assoc_type(
1926+
traits::transitive_bounds_that_define_assoc_item(
19271927
tcx,
19281928
predicates.iter().filter_map(|(p, _)| {
19291929
Some(p.to_opt_poly_trait_pred()?.map_bound(|t| t.trait_ref))

compiler/rustc_hir_analysis/src/collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ pub fn provide(providers: &mut Providers) {
6464
explicit_predicates_of: predicates_of::explicit_predicates_of,
6565
super_predicates_of: predicates_of::super_predicates_of,
6666
implied_predicates_of: predicates_of::implied_predicates_of,
67-
super_predicates_that_define_assoc_type:
68-
predicates_of::super_predicates_that_define_assoc_type,
67+
super_predicates_that_define_assoc_item:
68+
predicates_of::super_predicates_that_define_assoc_item,
6969
trait_explicit_predicates_and_bounds: predicates_of::trait_explicit_predicates_and_bounds,
7070
type_param_predicates: predicates_of::type_param_predicates,
7171
trait_def,

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ pub(super) fn super_predicates_of(
565565
implied_predicates_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly)
566566
}
567567

568-
pub(super) fn super_predicates_that_define_assoc_type(
568+
pub(super) fn super_predicates_that_define_assoc_item(
569569
tcx: TyCtxt<'_>,
570570
(trait_def_id, assoc_name): (DefId, Ident),
571571
) -> ty::GenericPredicates<'_> {
@@ -640,7 +640,7 @@ pub(super) fn implied_predicates_with_filter(
640640
),
641641
PredicateFilter::SelfThatDefines(assoc_name) => (
642642
// Convert the bounds that follow the colon (or equal) that reference the associated name
643-
icx.astconv().compute_bounds_that_match_assoc_type(self_param_ty, bounds, assoc_name),
643+
icx.astconv().compute_bounds_that_match_assoc_item(self_param_ty, bounds, assoc_name),
644644
// Include where clause bounds for `Self` that reference the associated name
645645
icx.type_parameter_bounds_in_generics(
646646
generics,
@@ -819,7 +819,7 @@ impl<'tcx> ItemCtxt<'tcx> {
819819
hir::GenericBound::Trait(poly_trait_ref, _) => {
820820
let trait_ref = &poly_trait_ref.trait_ref;
821821
if let Some(trait_did) = trait_ref.trait_def_id() {
822-
self.tcx.trait_may_define_assoc_type(trait_did, assoc_name)
822+
self.tcx.trait_may_define_assoc_item(trait_did, assoc_name)
823823
} else {
824824
false
825825
}

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
17281728
assoc_name: Ident,
17291729
assoc_kind: ty::AssocKind,
17301730
) -> Option<(Vec<ty::BoundVariableKind>, &'tcx ty::AssocItem)> {
1731-
let trait_defines_associated_type_named = |trait_def_id: DefId| {
1731+
let trait_defines_associated_item_named = |trait_def_id: DefId| {
17321732
tcx.associated_items(trait_def_id).find_by_name_and_kind(
17331733
tcx,
17341734
assoc_name,
@@ -1752,10 +1752,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
17521752
_ => break None,
17531753
}
17541754

1755-
if let Some(assoc_item) = trait_defines_associated_type_named(def_id) {
1755+
if let Some(assoc_item) = trait_defines_associated_item_named(def_id) {
17561756
break Some((bound_vars.into_iter().collect(), assoc_item));
17571757
}
1758-
let predicates = tcx.super_predicates_that_define_assoc_type((def_id, assoc_name));
1758+
let predicates = tcx.super_predicates_that_define_assoc_item((def_id, assoc_name));
17591759
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
17601760
let bound_predicate = pred.kind();
17611761
match bound_predicate.skip_binder() {

compiler/rustc_infer/src/traits/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,11 @@ pub fn transitive_bounds<'tcx>(
376376
}
377377

378378
/// A specialized variant of `elaborate` that only elaborates trait references that may
379-
/// define the given associated type `assoc_name`. It uses the
380-
/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
379+
/// define the given associated item with the name `assoc_name`. It uses the
380+
/// `super_predicates_that_define_assoc_item` query to avoid enumerating super-predicates that
381381
/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
382382
/// `T::Item` and helps to avoid cycle errors (see e.g. #35237).
383-
pub fn transitive_bounds_that_define_assoc_type<'tcx>(
383+
pub fn transitive_bounds_that_define_assoc_item<'tcx>(
384384
tcx: TyCtxt<'tcx>,
385385
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
386386
assoc_name: Ident,
@@ -393,7 +393,7 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
393393
let anon_trait_ref = tcx.anonymize_bound_vars(trait_ref);
394394
if visited.insert(anon_trait_ref) {
395395
let super_predicates =
396-
tcx.super_predicates_that_define_assoc_type((trait_ref.def_id(), assoc_name));
396+
tcx.super_predicates_that_define_assoc_item((trait_ref.def_id(), assoc_name));
397397
for (super_predicate, _) in super_predicates.predicates {
398398
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
399399
if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {

compiler/rustc_middle/src/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ rustc_queries! {
569569
/// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
570570
/// subset of super-predicates that reference traits that define the given associated type.
571571
/// This is used to avoid cycles in resolving types like `T::Item`.
572-
query super_predicates_that_define_assoc_type(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
572+
query super_predicates_that_define_assoc_item(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
573573
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
574574
tcx.def_path_str(key.0),
575575
key.1

compiler/rustc_middle/src/ty/context.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -1567,16 +1567,11 @@ impl<'tcx> TyCtxt<'tcx> {
15671567

15681568
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
15691569
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
1570-
pub fn trait_may_define_assoc_type(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
1570+
pub fn trait_may_define_assoc_item(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
15711571
self.super_traits_of(trait_def_id).any(|trait_did| {
15721572
self.associated_items(trait_did)
1573-
.find_by_name_and_kinds(
1574-
self,
1575-
assoc_name,
1576-
&[ty::AssocKind::Type, ty::AssocKind::Const, ty::AssocKind::Fn],
1577-
trait_did,
1578-
)
1579-
.is_some()
1573+
.filter_by_name_unhygienic(assoc_name.name)
1574+
.any(|item| self.hygienic_eq(assoc_name, item.ident(self), trait_did))
15801575
})
15811576
}
15821577

compiler/rustc_trait_selection/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub use self::util::elaborate;
6262
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
6363
pub use self::util::{get_vtable_index_of_object_method, impl_item_is_final, upcast_choices};
6464
pub use self::util::{
65-
supertrait_def_ids, supertraits, transitive_bounds, transitive_bounds_that_define_assoc_type,
65+
supertrait_def_ids, supertraits, transitive_bounds, transitive_bounds_that_define_assoc_item,
6666
SupertraitDefIds,
6767
};
6868

0 commit comments

Comments
 (0)