@@ -34,8 +34,6 @@ use rustc_hir as hir;
3434use rustc_hir:: def_id:: DefId ;
3535use rustc_infer:: infer:: DefineOpaqueTypes ;
3636use rustc_infer:: infer:: LateBoundRegionConversionTime ;
37- use rustc_infer:: traits:: TraitEngine ;
38- use rustc_infer:: traits:: TraitEngineExt ;
3937use rustc_middle:: dep_graph:: { DepKind , DepNodeIndex } ;
4038use rustc_middle:: mir:: interpret:: ErrorHandled ;
4139use rustc_middle:: ty:: abstract_const:: NotConstEvaluatable ;
@@ -312,6 +310,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
312310 & mut self ,
313311 stack : & TraitObligationStack < ' o , ' tcx > ,
314312 ) -> SelectionResult < ' tcx , SelectionCandidate < ' tcx > > {
313+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
315314 // Watch out for overflow. This intentionally bypasses (and does
316315 // not update) the cache.
317316 self . check_recursion_limit ( & stack. obligation , & stack. obligation ) ?;
@@ -526,21 +525,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
526525 /// Evaluates whether the obligation `obligation` can be satisfied
527526 /// and returns an `EvaluationResult`. This is meant for the
528527 /// *initial* call.
528+ ///
529+ /// Do not use this directly, use `infcx.evaluate_obligation` instead.
529530 pub fn evaluate_root_obligation (
530531 & mut self ,
531532 obligation : & PredicateObligation < ' tcx > ,
532533 ) -> Result < EvaluationResult , OverflowError > {
534+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
533535 self . evaluation_probe ( |this| {
534536 let goal =
535537 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+ ) ?;
544542 // If the predicate has done any inference, then downgrade the
545543 // result to ambiguous.
546544 if this. infcx . shallow_resolve ( goal) != goal {
@@ -587,42 +585,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
587585 where
588586 I : IntoIterator < Item = PredicateObligation < ' tcx > > + std:: fmt:: Debug ,
589587 {
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) ;
604598 }
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 ) ;
620599 }
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)
626601 }
627602
628603 #[ instrument(
@@ -636,6 +611,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
636611 previous_stack : TraitObligationStackList < ' o , ' tcx > ,
637612 obligation : PredicateObligation < ' tcx > ,
638613 ) -> Result < EvaluationResult , OverflowError > {
614+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
639615 // `previous_stack` stores a `TraitObligation`, while `obligation` is
640616 // a `PredicateObligation`. These are distinct types, so we can't
641617 // use any `Option` combinator method that would force them to be
@@ -1179,6 +1155,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11791155 & mut self ,
11801156 stack : & TraitObligationStack < ' o , ' tcx > ,
11811157 ) -> Result < EvaluationResult , OverflowError > {
1158+ debug_assert ! ( !self . infcx. next_trait_solver( ) ) ;
11821159 // In intercrate mode, whenever any of the generics are unbound,
11831160 // there can always be an impl. Even if there are no impls in
11841161 // this crate, perhaps the type would be unified with
0 commit comments