@@ -2839,22 +2839,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
28392839 let msg =
28402840 format ! ( "{} and panic if the converted value doesn't fit" , msg. clone( ) ) ;
28412841 let mut suggestion = sugg. clone ( ) ;
2842- if !expr. span . in_derive_expansion ( ) {
2843- suggestion. push ( (
2844- expr. span . shrink_to_hi ( ) ,
2845- format ! ( "{close_paren}.try_into().unwrap()" ) ,
2846- ) ) ;
2847- }
2842+ suggestion. push ( (
2843+ expr. span . shrink_to_hi ( ) ,
2844+ format ! ( "{close_paren}.try_into().unwrap()" ) ,
2845+ ) ) ;
28482846 ( msg, suggestion)
28492847 } ;
2850-
2851- if !suggestion. is_empty ( ) {
2852- err. multipart_suggestion_verbose (
2853- msg,
2854- suggestion,
2855- Applicability :: MachineApplicable ,
2856- ) ;
2857- }
2848+ err. multipart_suggestion_verbose ( msg, suggestion, Applicability :: MachineApplicable ) ;
28582849 } ;
28592850
28602851 let suggest_to_change_suffix_or_into =
@@ -2905,8 +2896,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29052896 ( None , _) | ( _, None ) => ( true , true ) ,
29062897 _ => ( false , false ) ,
29072898 } ;
2908- suggest_to_change_suffix_or_into ( err, f2e_is_fallible, e2f_is_fallible) ;
2909- true
2899+ if !expr. span . in_derive_expansion ( ) {
2900+ suggest_to_change_suffix_or_into ( err, f2e_is_fallible, e2f_is_fallible) ;
2901+ true
2902+ } else {
2903+ false
2904+ }
29102905 }
29112906 ( ty:: Uint ( exp) , ty:: Uint ( found) ) => {
29122907 let ( f2e_is_fallible, e2f_is_fallible) = match ( exp. bit_width ( ) , found. bit_width ( ) )
@@ -2918,8 +2913,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29182913 ( None , _) | ( _, None ) => ( true , true ) ,
29192914 _ => ( false , false ) ,
29202915 } ;
2921- suggest_to_change_suffix_or_into ( err, f2e_is_fallible, e2f_is_fallible) ;
2922- true
2916+ if !expr. span . in_derive_expansion ( ) {
2917+ suggest_to_change_suffix_or_into ( err, f2e_is_fallible, e2f_is_fallible) ;
2918+ true
2919+ } else {
2920+ false
2921+ }
29232922 }
29242923 ( & ty:: Int ( exp) , & ty:: Uint ( found) ) => {
29252924 let ( f2e_is_fallible, e2f_is_fallible) = match ( exp. bit_width ( ) , found. bit_width ( ) )
0 commit comments