Skip to content

Commit 3dab259

Browse files
Split super_predicates_that_define_assoc_type query from super_predicates_of
1 parent 45749b2 commit 3dab259

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

compiler/rustc_hir_analysis/src/collect.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ pub fn provide(providers: &mut Providers) {
6464
predicates_defined_on,
6565
explicit_predicates_of: predicates_of::explicit_predicates_of,
6666
super_predicates_of: predicates_of::super_predicates_of,
67-
super_predicates_that_define_assoc_type:
68-
predicates_of::super_predicates_that_define_assoc_type,
67+
super_predicates_that_define_assoc_type: |tcx, (def_id, assoc_name)| {
68+
predicates_of::super_predicates_that_define_assoc_type(tcx, (def_id, Some(assoc_name)))
69+
},
6970
trait_explicit_predicates_and_bounds: predicates_of::trait_explicit_predicates_and_bounds,
7071
type_param_predicates: predicates_of::type_param_predicates,
7172
trait_def,

compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1749,8 +1749,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
17491749
if trait_defines_associated_type_named(def_id) {
17501750
break Some(bound_vars.into_iter().collect());
17511751
}
1752-
let predicates =
1753-
tcx.super_predicates_that_define_assoc_type((def_id, Some(assoc_name)));
1752+
let predicates = tcx.super_predicates_that_define_assoc_type((def_id, assoc_name));
17541753
let obligations = predicates.predicates.iter().filter_map(|&(pred, _)| {
17551754
let bound_predicate = pred.kind();
17561755
match bound_predicate.skip_binder() {

compiler/rustc_infer/src/traits/util.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,8 @@ pub fn transitive_bounds_that_define_assoc_type<'tcx>(
381381
while let Some(trait_ref) = stack.pop() {
382382
let anon_trait_ref = tcx.anonymize_bound_vars(trait_ref);
383383
if visited.insert(anon_trait_ref) {
384-
let super_predicates = tcx.super_predicates_that_define_assoc_type((
385-
trait_ref.def_id(),
386-
Some(assoc_name),
387-
));
384+
let super_predicates =
385+
tcx.super_predicates_that_define_assoc_type((trait_ref.def_id(), assoc_name));
388386
for (super_predicate, _) in super_predicates.predicates {
389387
let subst_predicate = super_predicate.subst_supertrait(tcx, &trait_ref);
390388
if let Some(binder) = subst_predicate.to_opt_poly_trait_pred() {

compiler/rustc_middle/src/query/keys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl Key for (LocalDefId, LocalDefId) {
230230
}
231231
}
232232

233-
impl Key for (DefId, Option<Ident>) {
233+
impl Key for (DefId, Ident) {
234234
type CacheSelector = DefaultCacheSelector<Self>;
235235

236236
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {

compiler/rustc_middle/src/query/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -631,10 +631,10 @@ rustc_queries! {
631631
/// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
632632
/// subset of super-predicates that reference traits that define the given associated type.
633633
/// This is used to avoid cycles in resolving types like `T::Item`.
634-
query super_predicates_that_define_assoc_type(key: (DefId, Option<rustc_span::symbol::Ident>)) -> ty::GenericPredicates<'tcx> {
635-
desc { |tcx| "computing the super traits of `{}`{}",
634+
query super_predicates_that_define_assoc_type(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
635+
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
636636
tcx.def_path_str(key.0),
637-
if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() },
637+
key.1
638638
}
639639
}
640640

0 commit comments

Comments
 (0)