@@ -2839,22 +2839,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2839
2839
let msg =
2840
2840
format ! ( "{} and panic if the converted value doesn't fit" , msg. clone( ) ) ;
2841
2841
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
+ ) ) ;
2848
2846
( msg, suggestion)
2849
2847
} ;
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 ) ;
2858
2849
} ;
2859
2850
2860
2851
let suggest_to_change_suffix_or_into =
@@ -2905,8 +2896,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2905
2896
( None , _) | ( _, None ) => ( true , true ) ,
2906
2897
_ => ( false , false ) ,
2907
2898
} ;
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
+ }
2910
2905
}
2911
2906
( ty:: Uint ( exp) , ty:: Uint ( found) ) => {
2912
2907
let ( f2e_is_fallible, e2f_is_fallible) = match ( exp. bit_width ( ) , found. bit_width ( ) )
@@ -2918,8 +2913,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2918
2913
( None , _) | ( _, None ) => ( true , true ) ,
2919
2914
_ => ( false , false ) ,
2920
2915
} ;
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
+ }
2923
2922
}
2924
2923
( & ty:: Int ( exp) , & ty:: Uint ( found) ) => {
2925
2924
let ( f2e_is_fallible, e2f_is_fallible) = match ( exp. bit_width ( ) , found. bit_width ( ) )
0 commit comments