Skip to content

Commit 5e8c586

Browse files
committed
Refactor hir::diagnostics::MissingMatchArms fields, better naming
1 parent 8f189f6 commit 5e8c586

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

crates/hir/src/diagnostics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ pub struct MismatchedArgCount {
199199

200200
#[derive(Debug)]
201201
pub struct MissingMatchArms {
202-
pub file: HirFileId,
203-
pub match_expr: AstPtr<ast::Expr>,
202+
pub scrutinee_expr: InFile<AstPtr<ast::Expr>>,
204203
pub uncovered_patterns: String,
205204
}
206205

crates/hir/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,11 +1628,13 @@ impl DefWithBody {
16281628
if let ast::Expr::MatchExpr(match_expr) =
16291629
&source_ptr.value.to_node(&root)
16301630
{
1631-
if let Some(match_expr) = match_expr.expr() {
1631+
if let Some(scrut_expr) = match_expr.expr() {
16321632
acc.push(
16331633
MissingMatchArms {
1634-
file: source_ptr.file_id,
1635-
match_expr: AstPtr::new(&match_expr),
1634+
scrutinee_expr: InFile::new(
1635+
source_ptr.file_id,
1636+
AstPtr::new(&scrut_expr),
1637+
),
16361638
uncovered_patterns,
16371639
}
16381640
.into(),

crates/ide-diagnostics/src/handlers/missing_match_arms.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use hir::InFile;
2-
31
use crate::{Diagnostic, DiagnosticsContext};
42

53
// Diagnostic: missing-match-arm
@@ -12,7 +10,7 @@ pub(crate) fn missing_match_arms(
1210
Diagnostic::new(
1311
"missing-match-arm",
1412
format!("missing match arm: {}", d.uncovered_patterns),
15-
ctx.sema.diagnostics_display_range(InFile::new(d.file, d.match_expr.clone().into())).range,
13+
ctx.sema.diagnostics_display_range(d.scrutinee_expr.clone().map(Into::into)).range,
1614
)
1715
}
1816

0 commit comments

Comments
 (0)