Skip to content

Commit 2b3867b

Browse files
committed
remove pred_known_to_hold_modulo_regions
1 parent 9ab257b commit 2b3867b

File tree

1 file changed

+3
-47
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+3
-47
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

+3-47
Original file line numberDiff line numberDiff line change
@@ -118,60 +118,16 @@ pub fn predicates_for_generics<'tcx>(
118118

119119
/// Determines whether the type `ty` is known to meet `bound` and
120120
/// returns true if so. Returns false if `ty` either does not meet
121-
/// `bound` or is not known to meet bound (note that this is
122-
/// conservative towards *no impl*, which is the opposite of the
123-
/// `evaluate` methods).
121+
/// `bound` or is not known to meet bound.
124122
pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
125123
infcx: &InferCtxt<'tcx>,
126124
param_env: ty::ParamEnv<'tcx>,
127125
ty: Ty<'tcx>,
128126
def_id: DefId,
129127
) -> bool {
130128
let trait_ref = ty::TraitRef::new(infcx.tcx, def_id, [ty]);
131-
pred_known_to_hold_modulo_regions(infcx, param_env, trait_ref)
132-
}
133-
134-
/// FIXME(@lcnr): this function doesn't seem right and shouldn't exist?
135-
///
136-
/// Ping me on zulip if you want to use this method and need help with finding
137-
/// an appropriate replacement.
138-
#[instrument(level = "debug", skip(infcx, param_env, pred), ret)]
139-
fn pred_known_to_hold_modulo_regions<'tcx>(
140-
infcx: &InferCtxt<'tcx>,
141-
param_env: ty::ParamEnv<'tcx>,
142-
pred: impl ToPredicate<'tcx>,
143-
) -> bool {
144-
let obligation = Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, pred);
145-
146-
let result = infcx.evaluate_obligation_no_overflow(&obligation);
147-
debug!(?result);
148-
149-
if result.must_apply_modulo_regions() {
150-
true
151-
} else if result.may_apply() {
152-
// Sometimes obligations are ambiguous because the recursive evaluator
153-
// is not smart enough, so we fall back to fulfillment when we're not certain
154-
// that an obligation holds or not. Even still, we must make sure that
155-
// the we do no inference in the process of checking this obligation.
156-
let goal = infcx.resolve_vars_if_possible((obligation.predicate, obligation.param_env));
157-
infcx.probe(|_| {
158-
let ocx = ObligationCtxt::new(infcx);
159-
ocx.register_obligation(obligation);
160-
161-
let errors = ocx.select_all_or_error();
162-
match errors.as_slice() {
163-
// Only known to hold if we did no inference.
164-
[] => infcx.shallow_resolve(goal) == goal,
165-
166-
errors => {
167-
debug!(?errors);
168-
false
169-
}
170-
}
171-
})
172-
} else {
173-
false
174-
}
129+
let obligation = Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, trait_ref);
130+
infcx.predicate_must_hold_modulo_regions(&obligation)
175131
}
176132

177133
#[instrument(level = "debug", skip(tcx, elaborated_env))]

0 commit comments

Comments
 (0)