@@ -8,17 +8,13 @@ use rustc_data_structures::{
88use rustc_hir as hir;
99use rustc_hir:: intravisit:: Visitor ;
1010use rustc_hir:: HirId ;
11- use rustc_infer:: {
12- infer:: { DefineOpaqueTypes , InferOk } ,
13- traits:: ObligationCause ,
14- } ;
11+ use rustc_infer:: infer:: { DefineOpaqueTypes , InferOk } ;
1512use rustc_middle:: bug;
1613use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitable } ;
1714use rustc_session:: lint;
1815use rustc_span:: DUMMY_SP ;
1916use rustc_span:: { def_id:: LocalDefId , Span } ;
20- use rustc_trait_selection:: traits:: ObligationCtxt ;
21- use rustc_type_ir:: TyVid ;
17+ use rustc_trait_selection:: traits:: { ObligationCause , ObligationCtxt } ;
2218
2319#[ derive( Copy , Clone ) ]
2420pub enum DivergingFallbackBehavior {
@@ -479,7 +475,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
479475 fn lint_obligations_broken_by_never_type_fallback_change (
480476 & self ,
481477 behavior : DivergingFallbackBehavior ,
482- diverging_vids : & [ TyVid ] ,
478+ diverging_vids : & [ ty :: TyVid ] ,
483479 ) {
484480 let DivergingFallbackBehavior :: FallbackToUnit = behavior else { return } ;
485481
@@ -489,7 +485,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
489485 }
490486
491487 // Returns errors which happen if fallback is set to `fallback`
492- let try_out = |fallback| {
488+ let remaining_errors_if_fallback_to = |fallback| {
493489 self . probe ( |_| {
494490 let obligations = self . fulfillment_cx . borrow ( ) . pending_obligations ( ) ;
495491 let ocx = ObligationCtxt :: new ( & self . infcx ) ;
@@ -498,7 +494,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
498494 for & diverging_vid in diverging_vids {
499495 let diverging_ty = Ty :: new_var ( self . tcx , diverging_vid) ;
500496
501- _ = ocx. eq ( & ObligationCause :: dummy ( ) , self . param_env , diverging_ty, fallback) ;
497+ ocx. eq ( & ObligationCause :: dummy ( ) , self . param_env , diverging_ty, fallback)
498+ . expect ( "expected diverging var to be unconstrained" ) ;
502499 }
503500
504501 ocx. select_where_possible ( )
@@ -507,9 +504,9 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
507504
508505 // If we have no errors with `fallback = ()`, but *do* have errors with `fallback = !`,
509506 // then this code will be broken by the never type fallback change.qba
510- let unit_errors = try_out ( self . tcx . types . unit ) ;
507+ let unit_errors = remaining_errors_if_fallback_to ( self . tcx . types . unit ) ;
511508 if unit_errors. is_empty ( )
512- && let never_errors = try_out ( self . tcx . types . never )
509+ && let never_errors = remaining_errors_if_fallback_to ( self . tcx . types . never )
513510 && !never_errors. is_empty ( )
514511 {
515512 self . tcx . emit_node_span_lint (
0 commit comments