@@ -48,7 +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 = check_must_use_ty ( cx, ty, & expr, s. span , "" ) ;
51
+ let type_permits_lack_of_use = check_must_use_ty ( cx, ty, & expr, s. span , "" , "" ) ;
52
52
53
53
let mut fn_warned = false ;
54
54
let mut op_warned = false ;
@@ -133,6 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
133
133
ty : Ty < ' tcx > ,
134
134
expr : & hir:: Expr ,
135
135
span : Span ,
136
+ descr_pre_path : & str ,
136
137
descr_post_path : & str ,
137
138
) -> bool {
138
139
if ty. is_unit ( ) || cx. tcx . is_ty_uninhabited_from (
@@ -142,14 +143,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
142
143
}
143
144
144
145
match ty. sty {
145
- ty:: Adt ( def, _) => check_must_use_def ( cx, def. did , span, "" , descr_post_path) ,
146
+ ty:: Adt ( ..) if ty. is_box ( ) => {
147
+ let boxed_ty = ty. boxed_ty ( ) ;
148
+ let descr_pre_path = & format ! ( "{}boxed " , descr_pre_path) ;
149
+ check_must_use_ty ( cx, boxed_ty, expr, span, descr_pre_path, descr_post_path)
150
+ }
151
+ ty:: Adt ( def, _) => {
152
+ check_must_use_def ( cx, def. did , span, descr_pre_path, descr_post_path)
153
+ }
146
154
ty:: Opaque ( def, _) => {
147
155
let mut has_emitted = false ;
148
156
for ( predicate, _) in & cx. tcx . predicates_of ( def) . predicates {
149
157
if let ty:: Predicate :: Trait ( ref poly_trait_predicate) = predicate {
150
158
let trait_ref = poly_trait_predicate. skip_binder ( ) . trait_ref ;
151
159
let def_id = trait_ref. def_id ;
152
- if check_must_use_def ( cx, def_id, span, "implementer of " , "" ) {
160
+ let descr_pre = & format ! ( "{}implementer of " , descr_pre_path) ;
161
+ if check_must_use_def ( cx, def_id, span, descr_pre, descr_post_path) {
153
162
has_emitted = true ;
154
163
break ;
155
164
}
@@ -162,7 +171,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
162
171
for predicate in binder. skip_binder ( ) . iter ( ) {
163
172
if let ty:: ExistentialPredicate :: Trait ( ref trait_ref) = predicate {
164
173
let def_id = trait_ref. def_id ;
165
- if check_must_use_def ( cx, def_id, span, "" , " trait object" ) {
174
+ let descr_post = & format ! ( " trait object{}" , descr_post_path) ;
175
+ if check_must_use_def ( cx, def_id, span, descr_pre_path, descr_post) {
166
176
has_emitted = true ;
167
177
break ;
168
178
}
@@ -181,7 +191,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
181
191
for ( i, ty) in tys. iter ( ) . map ( |k| k. expect_ty ( ) ) . enumerate ( ) {
182
192
let descr_post_path = & format ! ( " in tuple element {}" , i) ;
183
193
let span = * spans. get ( i) . unwrap_or ( & span) ;
184
- if check_must_use_ty ( cx, ty, expr, span, descr_post_path) {
194
+ if check_must_use_ty ( cx, ty, expr, span, descr_pre_path , descr_post_path) {
185
195
has_emitted = true ;
186
196
}
187
197
}
0 commit comments