Skip to content

Commit d9834b1

Browse files
Make predicate filter in probe_ty_param_bounds_in_generics more explicit
1 parent 17f8215 commit d9834b1

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,8 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
613613
let mut bounds = Bounds::default();
614614
icx.lowerer().lower_bounds(self_param_ty, superbounds, &mut bounds, ty::List::empty(), filter);
615615

616-
let where_bounds_that_match = icx.probe_ty_param_bounds_in_generics(
617-
generics,
618-
item.owner_id.def_id,
619-
self_param_ty,
620-
filter,
621-
);
616+
let where_bounds_that_match =
617+
icx.probe_ty_param_bounds_in_generics(generics, item.owner_id.def_id, filter);
622618

623619
// Combine the two lists to form the complete set of superbounds:
624620
let implied_bounds =
@@ -765,7 +761,6 @@ pub(super) fn type_param_predicates<'tcx>(
765761
(item_def_id, def_id, assoc_name): (LocalDefId, LocalDefId, Ident),
766762
) -> ty::EarlyBinder<'tcx, &'tcx [(ty::Clause<'tcx>, Span)]> {
767763
use rustc_hir::*;
768-
use rustc_middle::ty::Ty;
769764

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

780774
// Don't look for bounds where the type parameter isn't in scope.
781775
let parent = if item_def_id == param_owner {
@@ -812,7 +806,6 @@ pub(super) fn type_param_predicates<'tcx>(
812806
icx.probe_ty_param_bounds_in_generics(
813807
hir_generics,
814808
def_id,
815-
ty,
816809
PredicateFilter::SelfThatDefines(assoc_name),
817810
)
818811
.into_iter()
@@ -838,7 +831,6 @@ impl<'tcx> ItemCtxt<'tcx> {
838831
&self,
839832
hir_generics: &'tcx hir::Generics<'tcx>,
840833
param_def_id: LocalDefId,
841-
ty: Ty<'tcx>,
842834
filter: PredicateFilter,
843835
) -> Vec<(ty::Clause<'tcx>, Span)> {
844836
let mut bounds = Bounds::default();
@@ -848,13 +840,21 @@ impl<'tcx> ItemCtxt<'tcx> {
848840
continue;
849841
};
850842

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

859859
let bound_vars = self.tcx.late_bound_vars(predicate.hir_id);
860860
self.lowerer().lower_bounds(

0 commit comments

Comments
 (0)