@@ -257,6 +257,7 @@ fn do_normalize_predicates<'tcx>(
257257 predicates : Vec < ty:: Clause < ' tcx > > ,
258258) -> Result < Vec < ty:: Clause < ' tcx > > , ErrorGuaranteed > {
259259 let span = cause. span ;
260+ let original_predicates = predicates. clone ( ) ;
260261
261262 // FIXME. We should really... do something with these region
262263 // obligations. But this call just continues the older
@@ -283,6 +284,38 @@ fn do_normalize_predicates<'tcx>(
283284
284285 debug ! ( "do_normalize_predicates: normalized predicates = {:?}" , predicates) ;
285286
287+ // The next solver returns nothing for values that contains type error.
288+ // And type error should cause failure later. So we skip the consistency check.
289+ if !tcx. next_trait_solver_globally ( ) && !predicates. references_error ( ) {
290+ let infcx = tcx
291+ . infer_ctxt ( )
292+ . with_next_trait_solver ( true )
293+ . ignoring_regions ( )
294+ . build ( TypingMode :: non_body_analysis ( ) ) ;
295+ for ( orig_pred, pred_by_old) in original_predicates. into_iter ( ) . zip ( & predicates) {
296+ let inconsistent_pred_by_next =
297+ match crate :: solve:: deeply_normalize :: < _ , ScrubbedTraitError < ' tcx > > (
298+ infcx. at ( & cause, elaborated_env) ,
299+ orig_pred,
300+ ) {
301+ Ok ( pred_by_next) => {
302+ if pred_by_next == * pred_by_old {
303+ continue ;
304+ }
305+ Some ( pred_by_next)
306+ }
307+ Err ( _) => None ,
308+ } ;
309+ tcx. dcx ( ) . span_err (
310+ span,
311+ format ! (
312+ "inconsistency during normalizing env `{:#?}`, old={:#?}, next={:#?}" ,
313+ orig_pred, pred_by_old, inconsistent_pred_by_next
314+ ) ,
315+ ) ;
316+ }
317+ }
318+
286319 // We can use the `elaborated_env` here; the region code only
287320 // cares about declarations like `'a: 'b`.
288321 // FIXME: It's very weird that we ignore region obligations but apparently
0 commit comments