Make predicate filter in probe_ty_param_bounds_in_generics
more explicit
This commit is contained in:
parent
75eff9a574
commit
ac67d295b9
@ -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 =
|
||||
@ -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
|
||||
@ -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 {
|
||||
@ -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()
|
||||
@ -841,7 +834,6 @@ fn probe_ty_param_bounds_in_generics(
|
||||
&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();
|
||||
@ -851,13 +843,21 @@ fn probe_ty_param_bounds_in_generics(
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user