@@ -8,17 +8,13 @@ use rustc_data_structures::{
8
8
use rustc_hir as hir;
9
9
use rustc_hir:: intravisit:: Visitor ;
10
10
use rustc_hir:: HirId ;
11
- use rustc_infer:: {
12
- infer:: { DefineOpaqueTypes , InferOk } ,
13
- traits:: ObligationCause ,
14
- } ;
11
+ use rustc_infer:: infer:: { DefineOpaqueTypes , InferOk } ;
15
12
use rustc_middle:: bug;
16
13
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitable } ;
17
14
use rustc_session:: lint;
18
15
use rustc_span:: DUMMY_SP ;
19
16
use 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 } ;
22
18
23
19
#[ derive( Copy , Clone ) ]
24
20
pub enum DivergingFallbackBehavior {
@@ -475,7 +471,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
475
471
fn lint_obligations_broken_by_never_type_fallback_change (
476
472
& self ,
477
473
behavior : DivergingFallbackBehavior ,
478
- diverging_vids : & [ TyVid ] ,
474
+ diverging_vids : & [ ty :: TyVid ] ,
479
475
) {
480
476
let DivergingFallbackBehavior :: FallbackToUnit = behavior else { return } ;
481
477
@@ -485,7 +481,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
485
481
}
486
482
487
483
// Returns errors which happen if fallback is set to `fallback`
488
- let try_out = |fallback| {
484
+ let remaining_errors_if_fallback_to = |fallback| {
489
485
self . probe ( |_| {
490
486
let obligations = self . fulfillment_cx . borrow ( ) . pending_obligations ( ) ;
491
487
let ocx = ObligationCtxt :: new ( & self . infcx ) ;
@@ -494,7 +490,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
494
490
for & diverging_vid in diverging_vids {
495
491
let diverging_ty = Ty :: new_var ( self . tcx , diverging_vid) ;
496
492
497
- _ = ocx. eq ( & ObligationCause :: dummy ( ) , self . param_env , diverging_ty, fallback) ;
493
+ ocx. eq ( & ObligationCause :: dummy ( ) , self . param_env , diverging_ty, fallback)
494
+ . expect ( "expected diverging var to be unconstrained" ) ;
498
495
}
499
496
500
497
ocx. select_where_possible ( )
@@ -503,9 +500,9 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
503
500
504
501
// If we have no errors with `fallback = ()`, but *do* have errors with `fallback = !`,
505
502
// then this code will be broken by the never type fallback change.qba
506
- let unit_errors = try_out ( self . tcx . types . unit ) ;
503
+ let unit_errors = remaining_errors_if_fallback_to ( self . tcx . types . unit ) ;
507
504
if unit_errors. is_empty ( )
508
- && let never_errors = try_out ( self . tcx . types . never )
505
+ && let never_errors = remaining_errors_if_fallback_to ( self . tcx . types . never )
509
506
&& !never_errors. is_empty ( )
510
507
{
511
508
self . tcx . emit_node_span_lint (
0 commit comments