@@ -48,14 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
4848 }
4949
5050 let ty = cx. tables . expr_ty ( & expr) ;
51- let type_permits_lack_of_use = if ty. is_unit ( )
52- || cx. tcx . is_ty_uninhabited_from (
53- cx. tcx . hir ( ) . get_module_parent_by_hir_id ( expr. hir_id ) , ty)
54- {
55- true
56- } else {
57- check_must_use_ty ( cx, ty, & expr, s. span )
58- } ;
51+ let type_permits_lack_of_use = check_must_use_ty ( cx, ty, & expr, s. span ) ;
5952
6053 let mut fn_warned = false ;
6154 let mut op_warned = false ;
@@ -135,12 +128,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
135128 }
136129
137130 // Returns whether an error has been emitted (and thus another does not need to be later).
138- fn check_must_use_ty (
139- cx : & LateContext < ' _ , ' _ > ,
140- ty : Ty < ' _ > ,
131+ fn check_must_use_ty < ' tcx > (
132+ cx : & LateContext < ' _ , ' tcx > ,
133+ ty : Ty < ' tcx > ,
141134 expr : & hir:: Expr ,
142135 span : Span ,
143136 ) -> bool {
137+ if ty. is_unit ( ) || cx. tcx . is_ty_uninhabited_from (
138+ cx. tcx . hir ( ) . get_module_parent_by_hir_id ( expr. hir_id ) , ty)
139+ {
140+ return true ;
141+ }
142+
144143 match ty. sty {
145144 ty:: Adt ( def, _) => check_must_use_def ( cx, def. did , span, "" , "" ) ,
146145 ty:: Opaque ( def, _) => {
0 commit comments