Skip to content

Commit 5b3a06a

Browse files
committed
Call fully_solve_obligations instead of repeating code
1 parent ad094cd commit 5b3a06a

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
@@ -402,9 +402,7 @@ pub fn fully_solve_obligation<'tcx>(
402402
infcx: &InferCtxt<'tcx>,
403403
obligation: PredicateObligation<'tcx>,
404404
) -> Vec<FulfillmentError<'tcx>> {
405-
let ocx = ObligationCtxt::new(infcx);
406-
ocx.register_obligation(obligation);
407-
ocx.select_all_or_error()
405+
fully_solve_obligations(infcx, [obligation])
408406
}
409407

410408
/// Process a set of obligations (and any nested obligations that come from them)
@@ -428,9 +426,16 @@ pub fn fully_solve_bound<'tcx>(
428426
ty: Ty<'tcx>,
429427
bound: DefId,
430428
) -> Vec<FulfillmentError<'tcx>> {
431-
let ocx = ObligationCtxt::new(infcx);
432-
ocx.register_bound(cause, param_env, ty, bound);
433-
ocx.select_all_or_error()
429+
let tcx = infcx.tcx;
430+
let trait_ref = ty::TraitRef { def_id: bound, substs: tcx.mk_substs_trait(ty, []) };
431+
let obligation = Obligation {
432+
cause,
433+
recursion_depth: 0,
434+
param_env,
435+
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(tcx),
436+
};
437+
438+
fully_solve_obligation(infcx, obligation)
434439
}
435440

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

0 commit comments

Comments
 (0)