@@ -147,15 +147,15 @@ impl ExprValidator {
147
147
148
148
fn validate_match (
149
149
& mut self ,
150
- id : ExprId ,
151
150
match_expr : ExprId ,
151
+ scrutinee_expr : ExprId ,
152
152
arms : & [ MatchArm ] ,
153
153
db : & dyn HirDatabase ,
154
154
) {
155
155
let body = db. body ( self . owner ) ;
156
156
157
- let match_expr_ty = & self . infer [ match_expr ] ;
158
- if match_expr_ty . is_unknown ( ) {
157
+ let scrut_ty = & self . infer [ scrutinee_expr ] ;
158
+ if scrut_ty . is_unknown ( ) {
159
159
return ;
160
160
}
161
161
@@ -167,17 +167,17 @@ impl ExprValidator {
167
167
for arm in arms {
168
168
if let Some ( pat_ty) = self . infer . type_of_pat . get ( arm. pat ) {
169
169
// We only include patterns whose type matches the type
170
- // of the match expression. If we had an InvalidMatchArmPattern
170
+ // of the scrutinee expression. If we had an InvalidMatchArmPattern
171
171
// diagnostic or similar we could raise that in an else
172
172
// block here.
173
173
//
174
174
// When comparing the types, we also have to consider that rustc
175
- // will automatically de-reference the match expression type if
175
+ // will automatically de-reference the scrutinee expression type if
176
176
// necessary.
177
177
//
178
178
// FIXME we should use the type checker for this.
179
- if ( pat_ty == match_expr_ty
180
- || match_expr_ty
179
+ if ( pat_ty == scrut_ty
180
+ || scrut_ty
181
181
. as_reference ( )
182
182
. map ( |( match_expr_ty, ..) | match_expr_ty == pat_ty)
183
183
. unwrap_or ( false ) )
@@ -205,16 +205,16 @@ impl ExprValidator {
205
205
return ;
206
206
}
207
207
208
- let report = compute_match_usefulness ( & cx, & m_arms, match_expr_ty ) ;
208
+ let report = compute_match_usefulness ( & cx, & m_arms, scrut_ty ) ;
209
209
210
210
// FIXME Report unreacheble arms
211
211
// https://github.com/rust-lang/rust/blob/f31622a50/compiler/rustc_mir_build/src/thir/pattern/check_match.rs#L200
212
212
213
213
let witnesses = report. non_exhaustiveness_witnesses ;
214
214
if !witnesses. is_empty ( ) {
215
215
self . diagnostics . push ( BodyValidationDiagnostic :: MissingMatchArms {
216
- match_expr : id ,
217
- uncovered_patterns : missing_match_arms ( & cx, match_expr_ty , witnesses, arms) ,
216
+ match_expr,
217
+ uncovered_patterns : missing_match_arms ( & cx, scrut_ty , witnesses, arms) ,
218
218
} ) ;
219
219
}
220
220
}
0 commit comments