Split super_predicates_that_define_assoc_type query from super_predicates_of
This commit is contained in:
parent
45749b21b7
commit
3dab259cb9
5 changed files with 10 additions and 12 deletions
|
@ -64,8 +64,9 @@ pub fn provide(providers: &mut Providers) {
|
|||
predicates_defined_on,
|
||||
explicit_predicates_of: predicates_of::explicit_predicates_of,
|
||||
super_predicates_of: predicates_of::super_predicates_of,
|
||||
super_predicates_that_define_assoc_type:
|
||||
predicates_of::super_predicates_that_define_assoc_type,
|
||||
super_predicates_that_define_assoc_type: |tcx, (def_id, assoc_name)| {
|
||||
predicates_of::super_predicates_that_define_assoc_type(tcx, (def_id, Some(assoc_name)))
|
||||
},
|
||||
trait_explicit_predicates_and_bounds: predicates_of::trait_explicit_predicates_and_bounds,
|
||||
type_param_predicates: predicates_of::type_param_predicates,
|
||||
trait_def,
|
||||
|
|
|
@ -1749,8 +1749,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
|
|||
if trait_defines_associated_type_named(def_id) {
|
||||
break Some(bound_vars.into_iter().collect());
|
||||
}
|
||||
let predicates =
|
||||
tcx.super_predicates_that_define_assoc_type((def_id, Some(assoc_name)));
|
||||
let predicates = tcx.super_predicates_that_define_assoc_type((def_id, assoc_name));
|
||||
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
|
||||
let bound_predicate = pred.kind();
|
||||
match bound_predicate.skip_binder() {
|
||||
|
|
|
@ -381,10 +381,8 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
|
|||
while let Some(trait_ref) = stack.pop() {
|
||||
let anon_trait_ref = tcx.anonymize_bound_vars(trait_ref);
|
||||
if visited.insert(anon_trait_ref) {
|
||||
let super_predicates = tcx.super_predicates_that_define_assoc_type((
|
||||
trait_ref.def_id(),
|
||||
Some(assoc_name),
|
||||
));
|
||||
let super_predicates =
|
||||
tcx.super_predicates_that_define_assoc_type((trait_ref.def_id(), assoc_name));
|
||||
for (super_predicate, _) in super_predicates.predicates {
|
||||
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
|
||||
if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {
|
||||
|
|
|
@ -230,7 +230,7 @@ impl Key for (LocalDefId, LocalDefId) {
|
|||
}
|
||||
}
|
||||
|
||||
impl Key for (DefId, Option<Ident>) {
|
||||
impl Key for (DefId, Ident) {
|
||||
type CacheSelector = DefaultCacheSelector<Self>;
|
||||
|
||||
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
|
||||
|
|
|
@ -631,10 +631,10 @@ rustc_queries! {
|
|||
/// 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.
|
||||
/// This is used to avoid cycles in resolving types like `T::Item`.
|
||||
query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
|
||||
desc { |tcx| "computing the super traits of `{}`{}",
|
||||
query super_predicates_that_define_assoc_type(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
|
||||
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
|
||||
tcx.def_path_str(key.0),
|
||||
if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
|
||||
key.1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue