@@ -34,8 +34,6 @@ use rustc_hir as hir;
34
34
use rustc_hir:: def_id:: DefId ;
35
35
use rustc_infer:: infer:: DefineOpaqueTypes ;
36
36
use rustc_infer:: infer:: LateBoundRegionConversionTime ;
37
- use rustc_infer:: traits:: TraitEngine ;
38
- use rustc_infer:: traits:: TraitEngineExt ;
39
37
use rustc_middle:: dep_graph:: { DepKind , DepNodeIndex } ;
40
38
use rustc_middle:: mir:: interpret:: ErrorHandled ;
41
39
use rustc_middle:: ty:: abstract_const:: NotConstEvaluatable ;
@@ -312,6 +310,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
312
310
& mut self ,
313
311
stack : & TraitObligationStack < ' o , ' tcx > ,
314
312
) -> SelectionResult < ' tcx , SelectionCandidate < ' tcx > > {
313
+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
315
314
// Watch out for overflow. This intentionally bypasses (and does
316
315
// not update) the cache.
317
316
self . check_recursion_limit ( & stack. obligation , & stack. obligation ) ?;
@@ -526,21 +525,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
526
525
/// Evaluates whether the obligation `obligation` can be satisfied
527
526
/// and returns an `EvaluationResult`. This is meant for the
528
527
/// *initial* call.
528
+ ///
529
+ /// Do not use this directly, use `infcx.evaluate_obligation` instead.
529
530
pub fn evaluate_root_obligation (
530
531
& mut self ,
531
532
obligation : & PredicateObligation < ' tcx > ,
532
533
) -> Result < EvaluationResult , OverflowError > {
534
+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
533
535
self . evaluation_probe ( |this| {
534
536
let goal =
535
537
this. infcx . resolve_vars_if_possible ( ( obligation. predicate , obligation. param_env ) ) ;
536
- let mut result = if this. infcx . next_trait_solver ( ) {
537
- this. evaluate_predicates_recursively_in_new_solver ( [ obligation. clone ( ) ] ) ?
538
- } else {
539
- this. evaluate_predicate_recursively (
540
- TraitObligationStackList :: empty ( & ProvisionalEvaluationCache :: default ( ) ) ,
541
- obligation. clone ( ) ,
542
- ) ?
543
- } ;
538
+ let mut result = this. evaluate_predicate_recursively (
539
+ TraitObligationStackList :: empty ( & ProvisionalEvaluationCache :: default ( ) ) ,
540
+ obligation. clone ( ) ,
541
+ ) ?;
544
542
// If the predicate has done any inference, then downgrade the
545
543
// result to ambiguous.
546
544
if this. infcx . shallow_resolve ( goal) != goal {
@@ -587,42 +585,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
587
585
where
588
586
I : IntoIterator < Item = PredicateObligation < ' tcx > > + std:: fmt:: Debug ,
589
587
{
590
- if self . infcx . next_trait_solver ( ) {
591
- self . evaluate_predicates_recursively_in_new_solver ( predicates)
592
- } else {
593
- let mut result = EvaluatedToOk ;
594
- for mut obligation in predicates {
595
- obligation. set_depth_from_parent ( stack. depth ( ) ) ;
596
- let eval = self . evaluate_predicate_recursively ( stack, obligation. clone ( ) ) ?;
597
- if let EvaluatedToErr = eval {
598
- // fast-path - EvaluatedToErr is the top of the lattice,
599
- // so we don't need to look on the other predicates.
600
- return Ok ( EvaluatedToErr ) ;
601
- } else {
602
- result = cmp:: max ( result, eval) ;
603
- }
588
+ let mut result = EvaluatedToOk ;
589
+ for mut obligation in predicates {
590
+ obligation. set_depth_from_parent ( stack. depth ( ) ) ;
591
+ let eval = self . evaluate_predicate_recursively ( stack, obligation. clone ( ) ) ?;
592
+ if let EvaluatedToErr = eval {
593
+ // fast-path - EvaluatedToErr is the top of the lattice,
594
+ // so we don't need to look on the other predicates.
595
+ return Ok ( EvaluatedToErr ) ;
596
+ } else {
597
+ result = cmp:: max ( result, eval) ;
604
598
}
605
- Ok ( result)
606
- }
607
- }
608
-
609
- /// Evaluates the predicates using the new solver when `-Ztrait-solver=next` is enabled
610
- fn evaluate_predicates_recursively_in_new_solver (
611
- & mut self ,
612
- predicates : impl IntoIterator < Item = PredicateObligation < ' tcx > > ,
613
- ) -> Result < EvaluationResult , OverflowError > {
614
- let mut fulfill_cx = crate :: solve:: FulfillmentCtxt :: new ( self . infcx ) ;
615
- fulfill_cx. register_predicate_obligations ( self . infcx , predicates) ;
616
- // True errors
617
- // FIXME(-Ztrait-solver=next): Overflows are reported as ambig here, is that OK?
618
- if !fulfill_cx. select_where_possible ( self . infcx ) . is_empty ( ) {
619
- return Ok ( EvaluatedToErr ) ;
620
599
}
621
- if !fulfill_cx. select_all_or_error ( self . infcx ) . is_empty ( ) {
622
- return Ok ( EvaluatedToAmbig ) ;
623
- }
624
- // Regions and opaques are handled in the `evaluation_probe` by looking at the snapshot
625
- Ok ( EvaluatedToOk )
600
+ Ok ( result)
626
601
}
627
602
628
603
#[ instrument(
@@ -636,6 +611,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
636
611
previous_stack : TraitObligationStackList < ' o , ' tcx > ,
637
612
obligation : PredicateObligation < ' tcx > ,
638
613
) -> Result < EvaluationResult , OverflowError > {
614
+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
639
615
// `previous_stack` stores a `TraitObligation`, while `obligation` is
640
616
// a `PredicateObligation`. These are distinct types, so we can't
641
617
// use any `Option` combinator method that would force them to be
@@ -1179,6 +1155,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1179
1155
& mut self ,
1180
1156
stack : & TraitObligationStack < ' o , ' tcx > ,
1181
1157
) -> Result < EvaluationResult , OverflowError > {
1158
+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
1182
1159
// In intercrate mode, whenever any of the generics are unbound,
1183
1160
// there can always be an impl. Even if there are no impls in
1184
1161
// this crate, perhaps the type would be unified with
0 commit comments