@@ -123,7 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
123123        let  must_use_result = is_ty_must_use ( cx,  ty,  & expr,  expr. span ) ; 
124124        let  type_lint_emitted_or_suppressed = match  must_use_result { 
125125            Some ( path)  => { 
126-                 emit_must_use_untranslated ( cx,  & path,  "" ,  "" ,  1 ) ; 
126+                 emit_must_use_untranslated ( cx,  & path,  "" ,  "" ,  1 ,   false ) ; 
127127                true 
128128            } 
129129            None  => false , 
@@ -358,6 +358,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
358358                        descr_pre_path, 
359359                        descr_post_path, 
360360                        1 , 
361+                         false , 
361362                    ) 
362363                } ) 
363364                . is_some ( ) 
@@ -370,27 +371,30 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
370371            descr_pre :  & str , 
371372            descr_post :  & str , 
372373            plural_len :  usize , 
374+             is_inner :  bool , 
373375        )  { 
374376            let  plural_suffix = pluralize ! ( plural_len) ; 
375377
376378            match  path { 
377379                MustUsePath :: Suppressed  => { } 
378380                MustUsePath :: Boxed ( path)  => { 
379381                    let  descr_pre = & format ! ( "{}boxed " ,  descr_pre) ; 
380-                     emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len) ; 
382+                     emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len,   true ) ; 
381383                } 
382384                MustUsePath :: Opaque ( path)  => { 
383385                    let  descr_pre = & format ! ( "{}implementer{} of " ,  descr_pre,  plural_suffix) ; 
384-                     emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len) ; 
386+                     emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len,   true ) ; 
385387                } 
386388                MustUsePath :: TraitObject ( path)  => { 
387389                    let  descr_post = & format ! ( " trait object{}{}" ,  plural_suffix,  descr_post) ; 
388-                     emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len) ; 
390+                     emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len,   true ) ; 
389391                } 
390392                MustUsePath :: TupleElement ( elems)  => { 
391393                    for  ( index,  path)  in  elems { 
392394                        let  descr_post = & format ! ( " in tuple element {}" ,  index) ; 
393-                         emit_must_use_untranslated ( cx,  path,  descr_pre,  descr_post,  plural_len) ; 
395+                         emit_must_use_untranslated ( 
396+                             cx,  path,  descr_pre,  descr_post,  plural_len,  true , 
397+                         ) ; 
394398                    } 
395399                } 
396400                MustUsePath :: Array ( path,  len)  => { 
@@ -401,6 +405,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
401405                        descr_pre, 
402406                        descr_post, 
403407                        plural_len. saturating_add ( usize:: try_from ( * len) . unwrap_or ( usize:: MAX ) ) , 
408+                         true , 
404409                    ) ; 
405410                } 
406411                MustUsePath :: Closure ( span)  => { 
@@ -418,19 +423,6 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
418423                    ) ; 
419424                } 
420425                MustUsePath :: Def ( span,  def_id,  reason)  => { 
421-                     let  suggestion = if  matches ! ( 
422-                         cx. tcx. get_diagnostic_name( * def_id) , 
423-                         Some ( sym:: add) 
424-                             | Some ( sym:: sub) 
425-                             | Some ( sym:: mul) 
426-                             | Some ( sym:: div) 
427-                             | Some ( sym:: rem) 
428-                             | Some ( sym:: neg) , 
429-                     )  { 
430-                         Some ( UnusedDefSuggestion :: Default  {  span :  span. shrink_to_lo ( )  } ) 
431-                     }  else  { 
432-                         None 
433-                     } ; 
434426                    cx. emit_spanned_lint ( 
435427                        UNUSED_MUST_USE , 
436428                        * span, 
@@ -440,7 +432,8 @@ impl<'tcx> LateLintPass<'tcx> for UnusedResults {
440432                            cx, 
441433                            def_id :  * def_id, 
442434                            note :  * reason, 
443-                             suggestion, 
435+                             suggestion :  ( !is_inner) 
436+                                 . then_some ( UnusedDefSuggestion  {  span :  span. shrink_to_lo ( )  } ) , 
444437                        } , 
445438                    ) ; 
446439                } 
0 commit comments