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 `!`
This commit is contained in:
commit
4305c1a89d
@ -1,6 +1,5 @@
|
|||||||
use rustc_middle::traits::solve::{Certainty, Goal, MaybeCause};
|
use rustc_middle::traits::solve::{Certainty, Goal, MaybeCause};
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_session::config::TraitSolver;
|
|
||||||
|
|
||||||
use crate::infer::canonical::OriginalQueryValues;
|
use crate::infer::canonical::OriginalQueryValues;
|
||||||
use crate::infer::InferCtxt;
|
use crate::infer::InferCtxt;
|
||||||
@ -80,13 +79,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
|||||||
_ => obligation.param_env.without_const(),
|
_ => obligation.param_env.without_const(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.tcx.sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
|
if self.tcx.trait_solver_next() {
|
||||||
let c_pred = self.canonicalize_query_keep_static(
|
|
||||||
param_env.and(obligation.predicate),
|
|
||||||
&mut _orig_values,
|
|
||||||
);
|
|
||||||
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
|
|
||||||
} else {
|
|
||||||
self.probe(|snapshot| {
|
self.probe(|snapshot| {
|
||||||
if let Ok((_, certainty)) =
|
if let Ok((_, certainty)) =
|
||||||
self.evaluate_root_goal(Goal::new(self.tcx, param_env, obligation.predicate))
|
self.evaluate_root_goal(Goal::new(self.tcx, param_env, obligation.predicate))
|
||||||
@ -111,6 +104,12 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
|
|||||||
Ok(EvaluationResult::EvaluatedToErr)
|
Ok(EvaluationResult::EvaluatedToErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
let c_pred = self.canonicalize_query_keep_static(
|
||||||
|
param_env.and(obligation.predicate),
|
||||||
|
&mut _orig_values,
|
||||||
|
);
|
||||||
|
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ use rustc_middle::ty::relate::TypeRelation;
|
|||||||
use rustc_middle::ty::SubstsRef;
|
use rustc_middle::ty::SubstsRef;
|
||||||
use rustc_middle::ty::{self, EarlyBinder, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
use rustc_middle::ty::{self, EarlyBinder, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
|
||||||
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
|
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
|
||||||
use rustc_session::config::TraitSolver;
|
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
@ -545,13 +544,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
) -> Result<EvaluationResult, OverflowError> {
|
) -> Result<EvaluationResult, OverflowError> {
|
||||||
self.evaluation_probe(|this| {
|
self.evaluation_probe(|this| {
|
||||||
if this.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
|
if this.tcx().trait_solver_next() {
|
||||||
|
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
|
||||||
|
} else {
|
||||||
this.evaluate_predicate_recursively(
|
this.evaluate_predicate_recursively(
|
||||||
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
|
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
|
||||||
obligation.clone(),
|
obligation.clone(),
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -591,7 +590,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
where
|
where
|
||||||
I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
|
I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
|
||||||
{
|
{
|
||||||
if self.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
|
if self.tcx().trait_solver_next() {
|
||||||
|
self.evaluate_predicates_recursively_in_new_solver(predicates)
|
||||||
|
} else {
|
||||||
let mut result = EvaluatedToOk;
|
let mut result = EvaluatedToOk;
|
||||||
for obligation in predicates {
|
for obligation in predicates {
|
||||||
let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
|
let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
|
||||||
@ -604,8 +605,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
} else {
|
|
||||||
self.evaluate_predicates_recursively_in_new_solver(predicates)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user