Skip to content

Commit

Permalink
Make predicate filter in probe_ty_param_bounds_in_generics more exp…
Browse files Browse the repository at this point in the history
…licit
  • Loading branch information
compiler-errors committed Oct 31, 2024
1 parent 75eff9a commit ac67d29
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,12 +606,8 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
let mut bounds = Bounds::default();
icx.lowerer().lower_bounds(self_param_ty, superbounds, &mut bounds, ty::List::empty(), filter);

let where_bounds_that_match = icx.probe_ty_param_bounds_in_generics(
generics,
item.owner_id.def_id,
self_param_ty,
filter,
);
let where_bounds_that_match =
icx.probe_ty_param_bounds_in_generics(generics, item.owner_id.def_id, filter);

// Combine the two lists to form the complete set of superbounds:
let implied_bounds =
Expand Down Expand Up @@ -768,7 +764,6 @@ pub(super) fn type_param_predicates<'tcx>(
}

use rustc_hir::*;
use rustc_middle::ty::Ty;

// In the HIR, bounds can derive from two places. Either
// written inline like `<T: Foo>` or in a where-clause like
Expand All @@ -778,7 +773,6 @@ pub(super) fn type_param_predicates<'tcx>(
let param_owner = tcx.hir().ty_param_owner(def_id);
let generics = tcx.generics_of(param_owner);
let index = generics.param_def_id_to_index[&def_id.to_def_id()];
let ty = Ty::new_param(tcx, index, tcx.hir().ty_param_name(def_id));

// Don't look for bounds where the type parameter isn't in scope.
let parent = if item_def_id == param_owner {
Expand Down Expand Up @@ -815,7 +809,6 @@ pub(super) fn type_param_predicates<'tcx>(
icx.probe_ty_param_bounds_in_generics(
hir_generics,
def_id,
ty,
PredicateFilter::SelfThatDefines(assoc_name),
)
.into_iter()
Expand All @@ -841,7 +834,6 @@ impl<'tcx> ItemCtxt<'tcx> {
&self,
hir_generics: &'tcx hir::Generics<'tcx>,
param_def_id: LocalDefId,
ty: Ty<'tcx>,
filter: PredicateFilter,
) -> Vec<(ty::Clause<'tcx>, Span)> {
let mut bounds = Bounds::default();
Expand All @@ -851,13 +843,21 @@ impl<'tcx> ItemCtxt<'tcx> {
continue;
};

let bound_ty = if predicate.is_param_bound(param_def_id.to_def_id()) {
ty
} else if matches!(filter, PredicateFilter::All) {
self.lowerer().lower_ty_maybe_return_type_notation(predicate.bounded_ty)
} else {
continue;
};
match filter {
_ if predicate.is_param_bound(param_def_id.to_def_id()) => {
// Ok
}
PredicateFilter::All => {
// Ok
}
PredicateFilter::SelfOnly
| PredicateFilter::SelfThatDefines(_)
| PredicateFilter::SelfConstIfConst
| PredicateFilter::SelfAndAssociatedTypeBounds => continue,
PredicateFilter::ConstIfConst => unreachable!(),
}

let bound_ty = self.lowerer().lower_ty_maybe_return_type_notation(predicate.bounded_ty);

let bound_vars = self.tcx.late_bound_vars(predicate.hir_id);
self.lowerer().lower_bounds(
Expand Down

0 comments on commit ac67d29

Please sign in to comment.