@@ -1104,7 +1104,7 @@ pub(crate) struct Rust2024IncompatiblePat {
1104
1104
1105
1105
pub ( crate ) struct Rust2024IncompatiblePatSugg {
1106
1106
pub ( crate ) suggestion : Vec < ( Span , String ) > ,
1107
- pub ( crate ) kind : Rust2024IncompatiblePatSuggKind ,
1107
+ pub ( crate ) kind : Option < Rust2024IncompatiblePatSuggKind > ,
1108
1108
pub ( crate ) ref_pattern_count : usize ,
1109
1109
pub ( crate ) binding_mode_count : usize ,
1110
1110
}
@@ -1120,31 +1120,33 @@ impl Subdiagnostic for Rust2024IncompatiblePatSugg {
1120
1120
diag : & mut Diag < ' _ , G > ,
1121
1121
_f : & F ,
1122
1122
) {
1123
+ use Rust2024IncompatiblePatSuggKind :: * ;
1123
1124
let applicability =
1124
1125
if self . suggestion . iter ( ) . all ( |( span, _) | span. can_be_used_for_suggestions ( ) ) {
1125
1126
Applicability :: MachineApplicable
1126
1127
} else {
1127
1128
Applicability :: MaybeIncorrect
1128
1129
} ;
1129
- let derefs = if self . ref_pattern_count > 0 {
1130
- format ! ( "reference pattern{}" , pluralize!( self . ref_pattern_count) )
1131
- } else {
1132
- String :: new ( )
1133
- } ;
1134
- let modes = if self . binding_mode_count > 0 {
1135
- format ! ( "variable binding mode{}" , pluralize!( self . binding_mode_count) )
1130
+ let msg = if let Some ( kind) = self . kind {
1131
+ let derefs = if self . ref_pattern_count > 0 {
1132
+ format ! ( "reference pattern{}" , pluralize!( self . ref_pattern_count) )
1133
+ } else {
1134
+ String :: new ( )
1135
+ } ;
1136
+ let modes = if self . binding_mode_count > 0 {
1137
+ format ! ( "variable binding mode{}" , pluralize!( self . binding_mode_count) )
1138
+ } else {
1139
+ String :: new ( )
1140
+ } ;
1141
+ let and = if !derefs. is_empty ( ) && !modes. is_empty ( ) { " and " } else { "" } ;
1142
+ let ( old_visibility, new_visibility) = match kind {
1143
+ Subtractive => ( "" , "implicit" ) ,
1144
+ Additive => ( "implied " , "explicit" ) ,
1145
+ } ;
1146
+ format ! ( "make the {old_visibility}{derefs}{and}{modes} {new_visibility}" )
1136
1147
} else {
1137
- String :: new ( )
1148
+ "rewrite the pattern" . to_owned ( )
1138
1149
} ;
1139
- let and = if !derefs. is_empty ( ) && !modes. is_empty ( ) { " and " } else { "" } ;
1140
- let ( old_visibility, new_visibility) = match self . kind {
1141
- Rust2024IncompatiblePatSuggKind :: Subtractive => ( "" , "implicit" ) ,
1142
- Rust2024IncompatiblePatSuggKind :: Additive => ( "implied " , "explicit" ) ,
1143
- } ;
1144
- diag. multipart_suggestion_verbose (
1145
- format ! ( "make the {old_visibility}{derefs}{and}{modes} {new_visibility}" ) ,
1146
- self . suggestion ,
1147
- applicability,
1148
- ) ;
1150
+ diag. multipart_suggestion_verbose ( msg, self . suggestion , applicability) ;
1149
1151
}
1150
1152
}
0 commit comments