about summary refs log tree commit diff
diff options
context:
space:
mode:
authoriDawer <ilnur.iskhakov.oss@outlook.com>2023-03-10 18:21:54 +0500
committeriDawer <ilnur.iskhakov.oss@outlook.com>2023-03-10 18:22:32 +0500
commit5e8c586f3b8c1fc43e293a53317bafe9df0b77fe (patch)
tree6c45300373e0e3f3d7588fc1569efafa368ef5ea
parent8f189f62c671aab20f16f1ed5586351556ffe8bd (diff)
downloadrust-5e8c586f3b8c1fc43e293a53317bafe9df0b77fe.tar.gz
rust-5e8c586f3b8c1fc43e293a53317bafe9df0b77fe.zip
Refactor hir::diagnostics::MissingMatchArms fields, better naming
-rw-r--r--crates/hir/src/diagnostics.rs3
-rw-r--r--crates/hir/src/lib.rs8
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_match_arms.rs4
3 files changed, 7 insertions, 8 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs
index c257ee2ae3a..8f019a81b2d 100644
--- a/crates/hir/src/diagnostics.rs
+++ b/crates/hir/src/diagnostics.rs
@@ -199,8 +199,7 @@ pub struct MismatchedArgCount {
 
 #[derive(Debug)]
 pub struct MissingMatchArms {
-    pub file: HirFileId,
-    pub match_expr: AstPtr<ast::Expr>,
+    pub scrutinee_expr: InFile<AstPtr<ast::Expr>>,
     pub uncovered_patterns: String,
 }
 
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 92b31031ca1..72a4829445d 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1628,11 +1628,13 @@ impl DefWithBody {
                             if let ast::Expr::MatchExpr(match_expr) =
                                 &source_ptr.value.to_node(&root)
                             {
-                                if let Some(match_expr) = match_expr.expr() {
+                                if let Some(scrut_expr) = match_expr.expr() {
                                     acc.push(
                                         MissingMatchArms {
-                                            file: source_ptr.file_id,
-                                            match_expr: AstPtr::new(&match_expr),
+                                            scrutinee_expr: InFile::new(
+                                                source_ptr.file_id,
+                                                AstPtr::new(&scrut_expr),
+                                            ),
                                             uncovered_patterns,
                                         }
                                         .into(),
diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
index 5ded2f22309..ac4463331f2 100644
--- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
@@ -1,5 +1,3 @@
-use hir::InFile;
-
 use crate::{Diagnostic, DiagnosticsContext};
 
 // Diagnostic: missing-match-arm
@@ -12,7 +10,7 @@ pub(crate) fn missing_match_arms(
     Diagnostic::new(
         "missing-match-arm",
         format!("missing match arm: {}", d.uncovered_patterns),
-        ctx.sema.diagnostics_display_range(InFile::new(d.file, d.match_expr.clone().into())).range,
+        ctx.sema.diagnostics_display_range(d.scrutinee_expr.clone().map(Into::into)).range,
     )
 }