@@ -48,14 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
48
48
}
49
49
50
50
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 ) ;
59
52
60
53
let mut fn_warned = false ;
61
54
let mut op_warned = false ;
@@ -135,12 +128,18 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
135
128
}
136
129
137
130
// 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 > ,
141
134
expr : & hir:: Expr ,
142
135
span : Span ,
143
136
) -> 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
+
144
143
match ty. sty {
145
144
ty:: Adt ( def, _) => check_must_use_def ( cx, def. did , span, "" , "" ) ,
146
145
ty:: Opaque ( def, _) => {
0 commit comments