File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
crates/hir_ty/src/diagnostics Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change @@ -1126,6 +1126,25 @@ fn main() {
1126
1126
) ;
1127
1127
}
1128
1128
1129
+ #[ test]
1130
+ fn match_guard ( ) {
1131
+ check_diagnostics (
1132
+ r#"
1133
+ fn main() {
1134
+ match true {
1135
+ true if false => {}
1136
+ true => {}
1137
+ false => {}
1138
+ }
1139
+ match true {
1140
+ //^^^^ Missing match arm
1141
+ true if false => {}
1142
+ false => {}
1143
+ }
1144
+ "# ,
1145
+ ) ;
1146
+ }
1147
+
1129
1148
mod false_negatives {
1130
1149
//! The implementation of match checking here is a work in progress. As we roll this out, we
1131
1150
//! prefer false negatives to false positives (ideally there would be no false positives). This
@@ -1153,5 +1172,37 @@ fn main() {
1153
1172
"# ,
1154
1173
) ;
1155
1174
}
1175
+
1176
+ #[ test]
1177
+ fn reference_patterns_at_top_level ( ) {
1178
+ check_diagnostics (
1179
+ r#"
1180
+ fn main() {
1181
+ match &false {
1182
+ &true => {}
1183
+ // ^^^^^ Internal: match check bailed out
1184
+ }
1185
+ }
1186
+ "# ,
1187
+ ) ;
1188
+ }
1189
+
1190
+ #[ test]
1191
+ fn reference_patterns_in_fields ( ) {
1192
+ check_diagnostics (
1193
+ r#"
1194
+ fn main() {
1195
+ match (&false,) {
1196
+ (true,) => {}
1197
+ // ^^^^^^^ Internal: match check bailed out
1198
+ }
1199
+ match (&false,) {
1200
+ (&true,) => {}
1201
+ // ^^^^^^^^ Internal: match check bailed out
1202
+ }
1203
+ }
1204
+ "# ,
1205
+ ) ;
1206
+ }
1156
1207
}
1157
1208
}
You can’t perform that action at this time.
0 commit comments