@@ -48,7 +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 = 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 , "" , "" ) ;
5252
5353 let mut fn_warned = false ;
5454 let mut op_warned = false ;
@@ -133,6 +133,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
133133 ty : Ty < ' tcx > ,
134134 expr : & hir:: Expr ,
135135 span : Span ,
136+ descr_pre_path : & str ,
136137 descr_post_path : & str ,
137138 ) -> bool {
138139 if ty. is_unit ( ) || cx. tcx . is_ty_uninhabited_from (
@@ -142,14 +143,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
142143 }
143144
144145 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+ }
146154 ty:: Opaque ( def, _) => {
147155 let mut has_emitted = false ;
148156 for ( predicate, _) in & cx. tcx . predicates_of ( def) . predicates {
149157 if let ty:: Predicate :: Trait ( ref poly_trait_predicate) = predicate {
150158 let trait_ref = poly_trait_predicate. skip_binder ( ) . trait_ref ;
151159 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) {
153162 has_emitted = true ;
154163 break ;
155164 }
@@ -162,7 +171,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
162171 for predicate in binder. skip_binder ( ) . iter ( ) {
163172 if let ty:: ExistentialPredicate :: Trait ( ref trait_ref) = predicate {
164173 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) {
166176 has_emitted = true ;
167177 break ;
168178 }
@@ -181,7 +191,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
181191 for ( i, ty) in tys. iter ( ) . map ( |k| k. expect_ty ( ) ) . enumerate ( ) {
182192 let descr_post_path = & format ! ( " in tuple element {}" , i) ;
183193 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) {
185195 has_emitted = true ;
186196 }
187197 }
0 commit comments