Skip to content

Commit ac67d29

Browse files
Make predicate filter in probe_ty_param_bounds_in_generics more explicit
1 parent 75eff9a commit ac67d29

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,8 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
606606
let mut bounds = Bounds::default();
607607
icx.lowerer().lower_bounds(self_param_ty, superbounds, &mut bounds, ty::List::empty(), filter);
608608

609-
let where_bounds_that_match = icx.probe_ty_param_bounds_in_generics(
610-
generics,
611-
item.owner_id.def_id,
612-
self_param_ty,
613-
filter,
614-
);
609+
let where_bounds_that_match =
610+
icx.probe_ty_param_bounds_in_generics(generics, item.owner_id.def_id, filter);
615611

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

770766
use rustc_hir::*;
771-
use rustc_middle::ty::Ty;
772767

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

783777
// Don't look for bounds where the type parameter isn't in scope.
784778
let parent = if item_def_id == param_owner {
@@ -815,7 +809,6 @@ pub(super) fn type_param_predicates<'tcx>(
815809
icx.probe_ty_param_bounds_in_generics(
816810
hir_generics,
817811
def_id,
818-
ty,
819812
PredicateFilter::SelfThatDefines(assoc_name),
820813
)
821814
.into_iter()
@@ -841,7 +834,6 @@ impl<'tcx> ItemCtxt<'tcx> {
841834
&self,
842835
hir_generics: &'tcx hir::Generics<'tcx>,
843836
param_def_id: LocalDefId,
844-
ty: Ty<'tcx>,
845837
filter: PredicateFilter,
846838
) -> Vec<(ty::Clause<'tcx>, Span)> {
847839
let mut bounds = Bounds::default();
@@ -851,13 +843,21 @@ impl<'tcx> ItemCtxt<'tcx> {
851843
continue;
852844
};
853845

854-
let bound_ty = if predicate.is_param_bound(param_def_id.to_def_id()) {
855-
ty
856-
} else if matches!(filter, PredicateFilter::All) {
857-
self.lowerer().lower_ty_maybe_return_type_notation(predicate.bounded_ty)
858-
} else {
859-
continue;
860-
};
846+
match filter {
847+
_ if predicate.is_param_bound(param_def_id.to_def_id()) => {
848+
// Ok
849+
}
850+
PredicateFilter::All => {
851+
// Ok
852+
}
853+
PredicateFilter::SelfOnly
854+
| PredicateFilter::SelfThatDefines(_)
855+
| PredicateFilter::SelfConstIfConst
856+
| PredicateFilter::SelfAndAssociatedTypeBounds => continue,
857+
PredicateFilter::ConstIfConst => unreachable!(),
858+
}
859+
860+
let bound_ty = self.lowerer().lower_ty_maybe_return_type_notation(predicate.bounded_ty);
861861

862862
let bound_vars = self.tcx.late_bound_vars(predicate.hir_id);
863863
self.lowerer().lower_bounds(

0 commit comments

Comments
 (0)