File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
277277                return  Some ( MustUsePath :: Suppressed ) ; 
278278            } 
279279            let  parent_mod_did = cx. tcx . parent_module ( expr. hir_id ) . to_def_id ( ) ; 
280-             if  !ty. is_inhabited_from ( cx. tcx ,  parent_mod_did,  cx. typing_env ( ) )  { 
280+             let  is_uninhabited =
281+                 |t :  Ty < ' tcx > | !t. is_inhabited_from ( cx. tcx ,  parent_mod_did,  cx. typing_env ( ) ) ; 
282+             if  is_uninhabited ( ty)  { 
281283                return  Some ( MustUsePath :: Suppressed ) ; 
282284            } 
283285
@@ -295,23 +297,15 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
295297                ty:: Adt ( def,  args) 
296298                    if  cx. tcx . is_diagnostic_item ( sym:: Result ,  def. did ( ) ) 
297299                        && args. type_at ( 0 ) . is_unit ( ) 
298-                         && !args. type_at ( 1 ) . is_inhabited_from ( 
299-                             cx. tcx , 
300-                             parent_mod_did, 
301-                             cx. typing_env ( ) , 
302-                         )  =>
300+                         && is_uninhabited ( args. type_at ( 1 ) )  =>
303301                { 
304302                    Some ( MustUsePath :: Suppressed ) 
305303                } 
306304                // Suppress warnings on `ControlFlow<Uninhabited, ()>` (e.g. `ControlFlow<!, ()>`). 
307305                ty:: Adt ( def,  args) 
308306                    if  cx. tcx . is_diagnostic_item ( sym:: ControlFlow ,  def. did ( ) ) 
309307                        && args. type_at ( 1 ) . is_unit ( ) 
310-                         && !args. type_at ( 0 ) . is_inhabited_from ( 
311-                             cx. tcx , 
312-                             parent_mod_did, 
313-                             cx. typing_env ( ) , 
314-                         )  =>
308+                         && is_uninhabited ( args. type_at ( 0 ) )  =>
315309                { 
316310                    Some ( MustUsePath :: Suppressed ) 
317311                } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments