mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Rename things to reflect that they're not item specific
This commit is contained in:
parent
20a83144b2
commit
fef2f5b815
@ -1040,7 +1040,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
|
|
||||||
/// Convert the bounds in `ast_bounds` that refer to traits which define an associated type
|
/// Convert the bounds in `ast_bounds` that refer to traits which define an associated type
|
||||||
/// named `assoc_name` into ty::Bounds. Ignore the rest.
|
/// named `assoc_name` into ty::Bounds. Ignore the rest.
|
||||||
pub(crate) fn compute_bounds_that_match_assoc_type(
|
pub(crate) fn compute_bounds_that_match_assoc_item(
|
||||||
&self,
|
&self,
|
||||||
param_ty: Ty<'tcx>,
|
param_ty: Ty<'tcx>,
|
||||||
ast_bounds: &[hir::GenericBound<'_>],
|
ast_bounds: &[hir::GenericBound<'_>],
|
||||||
@ -1051,7 +1051,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
for ast_bound in ast_bounds {
|
for ast_bound in ast_bounds {
|
||||||
if let Some(trait_ref) = ast_bound.trait_ref()
|
if let Some(trait_ref) = ast_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_type(trait_did, assoc_name)
|
&& self.tcx().trait_may_define_assoc_item(trait_did, assoc_name)
|
||||||
{
|
{
|
||||||
result.push(ast_bound.clone());
|
result.push(ast_bound.clone());
|
||||||
}
|
}
|
||||||
@ -1923,7 +1923,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
let param_name = tcx.hir().ty_param_name(ty_param_def_id);
|
let param_name = tcx.hir().ty_param_name(ty_param_def_id);
|
||||||
self.one_bound_for_assoc_type(
|
self.one_bound_for_assoc_type(
|
||||||
|| {
|
|| {
|
||||||
traits::transitive_bounds_that_define_assoc_type(
|
traits::transitive_bounds_that_define_assoc_item(
|
||||||
tcx,
|
tcx,
|
||||||
predicates.iter().filter_map(|(p, _)| {
|
predicates.iter().filter_map(|(p, _)| {
|
||||||
Some(p.to_opt_poly_trait_pred()?.map_bound(|t| t.trait_ref))
|
Some(p.to_opt_poly_trait_pred()?.map_bound(|t| t.trait_ref))
|
||||||
|
@ -64,8 +64,8 @@ pub fn provide(providers: &mut Providers) {
|
|||||||
explicit_predicates_of: predicates_of::explicit_predicates_of,
|
explicit_predicates_of: predicates_of::explicit_predicates_of,
|
||||||
super_predicates_of: predicates_of::super_predicates_of,
|
super_predicates_of: predicates_of::super_predicates_of,
|
||||||
implied_predicates_of: predicates_of::implied_predicates_of,
|
implied_predicates_of: predicates_of::implied_predicates_of,
|
||||||
super_predicates_that_define_assoc_type:
|
super_predicates_that_define_assoc_item:
|
||||||
predicates_of::super_predicates_that_define_assoc_type,
|
predicates_of::super_predicates_that_define_assoc_item,
|
||||||
trait_explicit_predicates_and_bounds: predicates_of::trait_explicit_predicates_and_bounds,
|
trait_explicit_predicates_and_bounds: predicates_of::trait_explicit_predicates_and_bounds,
|
||||||
type_param_predicates: predicates_of::type_param_predicates,
|
type_param_predicates: predicates_of::type_param_predicates,
|
||||||
trait_def,
|
trait_def,
|
||||||
|
@ -565,7 +565,7 @@ pub(super) fn super_predicates_of(
|
|||||||
implied_predicates_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly)
|
implied_predicates_with_filter(tcx, trait_def_id.to_def_id(), PredicateFilter::SelfOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn super_predicates_that_define_assoc_type(
|
pub(super) fn super_predicates_that_define_assoc_item(
|
||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
(trait_def_id, assoc_name): (DefId, Ident),
|
(trait_def_id, assoc_name): (DefId, Ident),
|
||||||
) -> ty::GenericPredicates<'_> {
|
) -> ty::GenericPredicates<'_> {
|
||||||
@ -640,7 +640,7 @@ pub(super) fn implied_predicates_with_filter(
|
|||||||
),
|
),
|
||||||
PredicateFilter::SelfThatDefines(assoc_name) => (
|
PredicateFilter::SelfThatDefines(assoc_name) => (
|
||||||
// Convert the bounds that follow the colon (or equal) that reference the associated name
|
// Convert the bounds that follow the colon (or equal) that reference the associated name
|
||||||
icx.astconv().compute_bounds_that_match_assoc_type(self_param_ty, bounds, assoc_name),
|
icx.astconv().compute_bounds_that_match_assoc_item(self_param_ty, bounds, assoc_name),
|
||||||
// Include where clause bounds for `Self` that reference the associated name
|
// Include where clause bounds for `Self` that reference the associated name
|
||||||
icx.type_parameter_bounds_in_generics(
|
icx.type_parameter_bounds_in_generics(
|
||||||
generics,
|
generics,
|
||||||
@ -819,7 +819,7 @@ impl<'tcx> ItemCtxt<'tcx> {
|
|||||||
hir::GenericBound::Trait(poly_trait_ref, _) => {
|
hir::GenericBound::Trait(poly_trait_ref, _) => {
|
||||||
let trait_ref = &poly_trait_ref.trait_ref;
|
let trait_ref = &poly_trait_ref.trait_ref;
|
||||||
if let Some(trait_did) = trait_ref.trait_def_id() {
|
if let Some(trait_did) = trait_ref.trait_def_id() {
|
||||||
self.tcx.trait_may_define_assoc_type(trait_did, assoc_name)
|
self.tcx.trait_may_define_assoc_item(trait_did, assoc_name)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -1728,7 +1728,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||||||
assoc_name: Ident,
|
assoc_name: 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_type_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_name_and_kind(
|
||||||
tcx,
|
tcx,
|
||||||
assoc_name,
|
assoc_name,
|
||||||
@ -1752,10 +1752,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||||||
_ => break None,
|
_ => break None,
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(assoc_item) = trait_defines_associated_type_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.super_predicates_that_define_assoc_type((def_id, assoc_name));
|
let predicates = tcx.super_predicates_that_define_assoc_item((def_id, assoc_name));
|
||||||
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
||||||
let bound_predicate = pred.kind();
|
let bound_predicate = pred.kind();
|
||||||
match bound_predicate.skip_binder() {
|
match bound_predicate.skip_binder() {
|
||||||
|
@ -376,11 +376,11 @@ pub fn transitive_bounds<'tcx>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A specialized variant of `elaborate` that only elaborates trait references that may
|
/// A specialized variant of `elaborate` that only elaborates trait references that may
|
||||||
/// define the given associated type `assoc_name`. It uses the
|
/// define the given associated item with the name `assoc_name`. It uses the
|
||||||
/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that
|
/// `super_predicates_that_define_assoc_item` query to avoid enumerating super-predicates that
|
||||||
/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
|
/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or
|
||||||
/// `T::Item` and helps to avoid cycle errors (see e.g. #35237).
|
/// `T::Item` and helps to avoid cycle errors (see e.g. #35237).
|
||||||
pub fn transitive_bounds_that_define_assoc_type<'tcx>(
|
pub fn transitive_bounds_that_define_assoc_item<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
bounds: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
|
||||||
assoc_name: Ident,
|
assoc_name: Ident,
|
||||||
@ -393,7 +393,7 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
|
|||||||
let anon_trait_ref = tcx.anonymize_bound_vars(trait_ref);
|
let anon_trait_ref = tcx.anonymize_bound_vars(trait_ref);
|
||||||
if visited.insert(anon_trait_ref) {
|
if visited.insert(anon_trait_ref) {
|
||||||
let super_predicates =
|
let super_predicates =
|
||||||
tcx.super_predicates_that_define_assoc_type((trait_ref.def_id(), assoc_name));
|
tcx.super_predicates_that_define_assoc_item((trait_ref.def_id(), assoc_name));
|
||||||
for (super_predicate, _) in super_predicates.predicates {
|
for (super_predicate, _) in super_predicates.predicates {
|
||||||
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
|
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
|
||||||
if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {
|
if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {
|
||||||
|
@ -569,7 +569,7 @@ rustc_queries! {
|
|||||||
/// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
|
/// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
|
||||||
/// subset of super-predicates that reference traits that define the given associated type.
|
/// subset of super-predicates that reference traits that define the given associated type.
|
||||||
/// This is used to avoid cycles in resolving types like `T::Item`.
|
/// This is used to avoid cycles in resolving types like `T::Item`.
|
||||||
query super_predicates_that_define_assoc_type(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
|
query super_predicates_that_define_assoc_item(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
|
||||||
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
|
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
|
||||||
tcx.def_path_str(key.0),
|
tcx.def_path_str(key.0),
|
||||||
key.1
|
key.1
|
||||||
|
@ -1567,16 +1567,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
|
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
|
||||||
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
|
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
|
||||||
pub fn trait_may_define_assoc_type(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
|
pub fn trait_may_define_assoc_item(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
|
||||||
self.super_traits_of(trait_def_id).any(|trait_did| {
|
self.super_traits_of(trait_def_id).any(|trait_did| {
|
||||||
self.associated_items(trait_did)
|
self.associated_items(trait_did)
|
||||||
.find_by_name_and_kinds(
|
.filter_by_name_unhygienic(assoc_name.name)
|
||||||
self,
|
.any(|item| self.hygienic_eq(assoc_name, item.ident(self), trait_did))
|
||||||
assoc_name,
|
|
||||||
&[ty::AssocKind::Type, ty::AssocKind::Const, ty::AssocKind::Fn],
|
|
||||||
trait_did,
|
|
||||||
)
|
|
||||||
.is_some()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ pub use self::util::elaborate;
|
|||||||
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
|
pub use self::util::{expand_trait_aliases, TraitAliasExpander};
|
||||||
pub use self::util::{get_vtable_index_of_object_method, impl_item_is_final, upcast_choices};
|
pub use self::util::{get_vtable_index_of_object_method, impl_item_is_final, upcast_choices};
|
||||||
pub use self::util::{
|
pub use self::util::{
|
||||||
supertrait_def_ids, supertraits, transitive_bounds, transitive_bounds_that_define_assoc_type,
|
supertrait_def_ids, supertraits, transitive_bounds, transitive_bounds_that_define_assoc_item,
|
||||||
SupertraitDefIds,
|
SupertraitDefIds,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user