mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Simplify Diagnostic structure
It's not entirely clear what subnode ranges should mean in the presence of macros, so let's leave them out for now. We are not using them heavily anyway.
This commit is contained in:
parent
a8196ffe84
commit
146f6f5a45
6 changed files with 8 additions and 51 deletions
|
@ -3,7 +3,7 @@
|
|||
use std::any::Any;
|
||||
|
||||
use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile};
|
||||
use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr, TextRange};
|
||||
use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr};
|
||||
use stdx::format_to;
|
||||
|
||||
pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm};
|
||||
|
@ -13,7 +13,6 @@ pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink};
|
|||
pub struct NoSuchField {
|
||||
pub file: HirFileId,
|
||||
pub field: AstPtr<ast::RecordField>,
|
||||
pub highlight_range: TextRange,
|
||||
}
|
||||
|
||||
impl Diagnostic for NoSuchField {
|
||||
|
@ -21,10 +20,6 @@ impl Diagnostic for NoSuchField {
|
|||
"no such field".to_string()
|
||||
}
|
||||
|
||||
fn highlight_range(&self) -> InFile<TextRange> {
|
||||
InFile::new(self.file, self.highlight_range)
|
||||
}
|
||||
|
||||
fn source(&self) -> InFile<SyntaxNodePtr> {
|
||||
InFile::new(self.file, self.field.clone().into())
|
||||
}
|
||||
|
@ -38,7 +33,6 @@ impl Diagnostic for NoSuchField {
|
|||
pub struct MissingFields {
|
||||
pub file: HirFileId,
|
||||
pub field_list: AstPtr<ast::RecordFieldList>,
|
||||
pub highlight_range: TextRange,
|
||||
pub missed_fields: Vec<Name>,
|
||||
}
|
||||
|
||||
|
@ -50,10 +44,6 @@ impl Diagnostic for MissingFields {
|
|||
}
|
||||
buf
|
||||
}
|
||||
fn highlight_range(&self) -> InFile<TextRange> {
|
||||
InFile::new(self.file, self.highlight_range)
|
||||
}
|
||||
|
||||
fn source(&self) -> InFile<SyntaxNodePtr> {
|
||||
InFile { file_id: self.file, value: self.field_list.clone().into() }
|
||||
}
|
||||
|
@ -76,7 +66,6 @@ impl AstDiagnostic for MissingFields {
|
|||
pub struct MissingPatFields {
|
||||
pub file: HirFileId,
|
||||
pub field_list: AstPtr<ast::RecordFieldPatList>,
|
||||
pub highlight_range: TextRange,
|
||||
pub missed_fields: Vec<Name>,
|
||||
}
|
||||
|
||||
|
@ -88,9 +77,6 @@ impl Diagnostic for MissingPatFields {
|
|||
}
|
||||
buf
|
||||
}
|
||||
fn highlight_range(&self) -> InFile<TextRange> {
|
||||
InFile::new(self.file, self.highlight_range)
|
||||
}
|
||||
fn source(&self) -> InFile<SyntaxNodePtr> {
|
||||
InFile { file_id: self.file, value: self.field_list.clone().into() }
|
||||
}
|
||||
|
@ -104,16 +90,12 @@ pub struct MissingMatchArms {
|
|||
pub file: HirFileId,
|
||||
pub match_expr: AstPtr<ast::Expr>,
|
||||
pub arms: AstPtr<ast::MatchArmList>,
|
||||
pub highlight_range: TextRange,
|
||||
}
|
||||
|
||||
impl Diagnostic for MissingMatchArms {
|
||||
fn message(&self) -> String {
|
||||
String::from("Missing match arm")
|
||||
}
|
||||
fn highlight_range(&self) -> InFile<TextRange> {
|
||||
InFile::new(self.file, self.highlight_range)
|
||||
}
|
||||
fn source(&self) -> InFile<SyntaxNodePtr> {
|
||||
InFile { file_id: self.file, value: self.match_expr.clone().into() }
|
||||
}
|
||||
|
@ -126,16 +108,12 @@ impl Diagnostic for MissingMatchArms {
|
|||
pub struct MissingOkInTailExpr {
|
||||
pub file: HirFileId,
|
||||
pub expr: AstPtr<ast::Expr>,
|
||||
pub highlight_range: TextRange,
|
||||
}
|
||||
|
||||
impl Diagnostic for MissingOkInTailExpr {
|
||||
fn message(&self) -> String {
|
||||
"wrap return expression in Ok".to_string()
|
||||
}
|
||||
fn highlight_range(&self) -> InFile<TextRange> {
|
||||
InFile::new(self.file, self.highlight_range)
|
||||
}
|
||||
fn source(&self) -> InFile<SyntaxNodePtr> {
|
||||
InFile { file_id: self.file, value: self.expr.clone().into() }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue