mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 21:13:37 +00:00
Refactor hir::diagnostics::MissingMatchArms fields, better naming
This commit is contained in:
parent
8f189f62c6
commit
5e8c586f3b
3 changed files with 7 additions and 8 deletions
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue