From 935c53b92eea7c288b781ecd68436c9733ec8a83 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 13 Jun 2021 21:55:51 +0300 Subject: internal: use cov-mark rather than bailing out diagnostic --- crates/hir/src/diagnostics.rs | 23 ----------------------- crates/hir/src/lib.rs | 28 ++++++---------------------- 2 files changed, 6 insertions(+), 45 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 5cffef47f..1f6a70006 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs @@ -3,8 +3,6 @@ //! //! This probably isn't the best way to do this -- ideally, diagnistics should //! be expressed in terms of hir types themselves. -use std::any::Any; - use cfg::{CfgExpr, CfgOptions}; use either::Either; use hir_def::path::ModPath; @@ -157,25 +155,4 @@ pub struct MissingMatchArms { pub arms: AstPtr, } -#[derive(Debug)] -pub struct InternalBailedOut { - pub file: HirFileId, - pub pat_syntax_ptr: SyntaxNodePtr, -} - -impl Diagnostic for InternalBailedOut { - fn code(&self) -> DiagnosticCode { - DiagnosticCode("internal:match-check-bailed-out") - } - fn message(&self) -> String { - format!("Internal: match check bailed out") - } - fn display_source(&self) -> InFile { - InFile { file_id: self.file, value: self.pat_syntax_ptr.clone() } - } - fn as_any(&self) -> &(dyn Any + Send + 'static) { - self - } -} - pub use hir_ty::diagnostics::IncorrectCase; diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 2e794ff4a..7f689cd41 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -86,8 +86,8 @@ use crate::{ pub use crate::{ attrs::{HasAttrs, Namespace}, diagnostics::{ - AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase, InternalBailedOut, - MacroError, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, + AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase, MacroError, + MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap, UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, UnresolvedModule, UnresolvedProcMacro, @@ -461,7 +461,6 @@ impl Module { self, db: &dyn HirDatabase, sink: &mut DiagnosticSink, - internal_diagnostics: bool, ) -> Vec { let _p = profile::span("Module::diagnostics").detail(|| { format!("{:?}", self.name(db).map_or("".into(), |name| name.to_string())) @@ -619,11 +618,11 @@ impl Module { } for decl in self.declarations(db) { match decl { - ModuleDef::Function(f) => acc.extend(f.diagnostics(db, sink, internal_diagnostics)), + ModuleDef::Function(f) => acc.extend(f.diagnostics(db, sink)), ModuleDef::Module(m) => { // Only add diagnostics from inline modules if def_map[m.id.local_id].origin.is_inline() { - acc.extend(m.diagnostics(db, sink, internal_diagnostics)) + acc.extend(m.diagnostics(db, sink)) } } _ => acc.extend(decl.diagnostics(db)), @@ -633,7 +632,7 @@ impl Module { for impl_def in self.impl_defs(db) { for item in impl_def.items(db) { if let AssocItem::Function(f) = item { - acc.extend(f.diagnostics(db, sink, internal_diagnostics)); + acc.extend(f.diagnostics(db, sink)); } } } @@ -1040,7 +1039,6 @@ impl Function { self, db: &dyn HirDatabase, sink: &mut DiagnosticSink, - internal_diagnostics: bool, ) -> Vec { let mut acc: Vec = Vec::new(); let krate = self.module(db).id.krate(); @@ -1100,9 +1098,7 @@ impl Function { } } - for diagnostic in - BodyValidationDiagnostic::collect(db, self.id.into(), internal_diagnostics) - { + for diagnostic in BodyValidationDiagnostic::collect(db, self.id.into()) { match diagnostic { BodyValidationDiagnostic::RecordMissingFields { record, @@ -1223,18 +1219,6 @@ impl Function { Err(SyntheticSyntax) => (), } } - BodyValidationDiagnostic::InternalBailedOut { pat } => { - match source_map.pat_syntax(pat) { - Ok(source_ptr) => { - let pat_syntax_ptr = source_ptr.value.either(Into::into, Into::into); - sink.push(InternalBailedOut { - file: source_ptr.file_id, - pat_syntax_ptr, - }); - } - Err(SyntheticSyntax) => (), - } - } } } -- cgit v1.2.3