Skip to content

Commit 4305c1a

Browse files
authored
Rollup merge of #109032 - compiler-errors:shorter, r=BoxyUwU
Use `TyCtxt::trait_solver_next` in some places Also flip order of if statements to avoid `!`
2 parents 66f07c7 + d283452 commit 4305c1a

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

compiler/rustc_trait_selection/src/traits/query/evaluate_obligation.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use rustc_middle::traits::solve::{Certainty, Goal, MaybeCause};
22
use rustc_middle::ty;
3-
use rustc_session::config::TraitSolver;
43

54
use crate::infer::canonical::OriginalQueryValues;
65
use crate::infer::InferCtxt;
@@ -80,13 +79,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
8079
_ => obligation.param_env.without_const(),
8180
};
8281

83-
if self.tcx.sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
84-
let c_pred = self.canonicalize_query_keep_static(
85-
param_env.and(obligation.predicate),
86-
&mut _orig_values,
87-
);
88-
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
89-
} else {
82+
if self.tcx.trait_solver_next() {
9083
self.probe(|snapshot| {
9184
if let Ok((_, certainty)) =
9285
self.evaluate_root_goal(Goal::new(self.tcx, param_env, obligation.predicate))
@@ -111,6 +104,12 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
111104
Ok(EvaluationResult::EvaluatedToErr)
112105
}
113106
})
107+
} else {
108+
let c_pred = self.canonicalize_query_keep_static(
109+
param_env.and(obligation.predicate),
110+
&mut _orig_values,
111+
);
112+
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
114113
}
115114
}
116115

compiler/rustc_trait_selection/src/traits/select/mod.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ use rustc_middle::ty::relate::TypeRelation;
5050
use rustc_middle::ty::SubstsRef;
5151
use rustc_middle::ty::{self, EarlyBinder, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
5252
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
53-
use rustc_session::config::TraitSolver;
5453
use rustc_span::symbol::sym;
5554

5655
use std::cell::{Cell, RefCell};
@@ -545,13 +544,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
545544
obligation: &PredicateObligation<'tcx>,
546545
) -> Result<EvaluationResult, OverflowError> {
547546
self.evaluation_probe(|this| {
548-
if this.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
547+
if this.tcx().trait_solver_next() {
548+
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
549+
} else {
549550
this.evaluate_predicate_recursively(
550551
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
551552
obligation.clone(),
552553
)
553-
} else {
554-
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
555554
}
556555
})
557556
}
@@ -591,7 +590,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
591590
where
592591
I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
593592
{
594-
if self.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
593+
if self.tcx().trait_solver_next() {
594+
self.evaluate_predicates_recursively_in_new_solver(predicates)
595+
} else {
595596
let mut result = EvaluatedToOk;
596597
for obligation in predicates {
597598
let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
@@ -604,8 +605,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
604605
}
605606
}
606607
Ok(result)
607-
} else {
608-
self.evaluate_predicates_recursively_in_new_solver(predicates)
609608
}
610609
}
611610

0 commit comments

Comments
 (0)