Skip to content

Commit 23422a8

Browse files
committed
Call fully_solve_obligations instead of repeating code
1 parent 83701f5 commit 23422a8

File tree

1 file changed

+11
-6
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+11
-6
lines changed

compiler/rustc_trait_selection/src/traits/mod.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,7 @@ pub fn fully_solve_obligation<'tcx>(
394394
infcx: &InferCtxt<'tcx>,
395395
obligation: PredicateObligation<'tcx>,
396396
) -> Vec<FulfillmentError<'tcx>> {
397-
let ocx = ObligationCtxt::new(infcx);
398-
ocx.register_obligation(obligation);
399-
ocx.select_all_or_error()
397+
fully_solve_obligations(infcx, [obligation])
400398
}
401399

402400
/// Process a set of obligations (and any nested obligations that come from them)
@@ -420,9 +418,16 @@ pub fn fully_solve_bound<'tcx>(
420418
ty: Ty<'tcx>,
421419
bound: DefId,
422420
) -> Vec<FulfillmentError<'tcx>> {
423-
let ocx = ObligationCtxt::new(infcx);
424-
ocx.register_bound(cause, param_env, ty, bound);
425-
ocx.select_all_or_error()
421+
let tcx = infcx.tcx;
422+
let trait_ref = ty::TraitRef { def_id: bound, substs: tcx.mk_substs_trait(ty, &[]) };
423+
let obligation = Obligation {
424+
cause,
425+
recursion_depth: 0,
426+
param_env,
427+
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
428+
};
429+
430+
fully_solve_obligation(infcx, obligation)
426431
}
427432

428433
/// Normalizes the predicates and checks whether they hold in an empty environment. If this

0 commit comments

Comments
 (0)