Skip to content

Commit 7653066

Browse files
bors[bot]matklad
andauthored
Merge #9255
9255: internal: remove DiagnosticWithFix infra r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 2ad7892 + 3478897 commit 7653066

File tree

8 files changed

+713
-794
lines changed

8 files changed

+713
-794
lines changed

crates/hir/src/diagnostics.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ macro_rules! diagnostics {
3434
diagnostics![
3535
BreakOutsideOfLoop,
3636
InactiveCode,
37+
IncorrectCase,
3738
MacroError,
3839
MismatchedArgCount,
3940
MissingFields,
@@ -195,31 +196,3 @@ impl Diagnostic for InternalBailedOut {
195196
}
196197

197198
pub use hir_ty::diagnostics::IncorrectCase;
198-
199-
impl Diagnostic for IncorrectCase {
200-
fn code(&self) -> DiagnosticCode {
201-
DiagnosticCode("incorrect-ident-case")
202-
}
203-
204-
fn message(&self) -> String {
205-
format!(
206-
"{} `{}` should have {} name, e.g. `{}`",
207-
self.ident_type,
208-
self.ident_text,
209-
self.expected_case.to_string(),
210-
self.suggested_text
211-
)
212-
}
213-
214-
fn display_source(&self) -> InFile<SyntaxNodePtr> {
215-
InFile::new(self.file, self.ident.clone().into())
216-
}
217-
218-
fn as_any(&self) -> &(dyn Any + Send + 'static) {
219-
self
220-
}
221-
222-
fn is_experimental(&self) -> bool {
223-
true
224-
}
225-
}

crates/hir/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ use crate::{
8686
pub use crate::{
8787
attrs::{HasAttrs, Namespace},
8888
diagnostics::{
89-
AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, InternalBailedOut, MacroError,
90-
MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr,
89+
AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase, InternalBailedOut,
90+
MacroError, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr,
9191
MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap,
9292
UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall,
9393
UnresolvedModule, UnresolvedProcMacro,
@@ -340,7 +340,7 @@ impl ModuleDef {
340340
}
341341
}
342342

343-
pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
343+
pub fn diagnostics(self, db: &dyn HirDatabase) -> Vec<AnyDiagnostic> {
344344
let id = match self {
345345
ModuleDef::Adt(it) => match it {
346346
Adt::Struct(it) => it.id.into(),
@@ -353,17 +353,19 @@ impl ModuleDef {
353353
ModuleDef::Module(it) => it.id.into(),
354354
ModuleDef::Const(it) => it.id.into(),
355355
ModuleDef::Static(it) => it.id.into(),
356-
_ => return,
356+
_ => return Vec::new(),
357357
};
358358

359359
let module = match self.module(db) {
360360
Some(it) => it,
361-
None => return,
361+
None => return Vec::new(),
362362
};
363363

364+
let mut acc = Vec::new();
364365
for diag in hir_ty::diagnostics::validate_module_item(db, module.id.krate(), id) {
365-
sink.push(diag)
366+
acc.push(diag.into())
366367
}
368+
acc
367369
}
368370
}
369371

@@ -624,7 +626,7 @@ impl Module {
624626
acc.extend(m.diagnostics(db, sink, internal_diagnostics))
625627
}
626628
}
627-
_ => decl.diagnostics(db, sink),
629+
_ => acc.extend(decl.diagnostics(db)),
628630
}
629631
}
630632

@@ -1234,7 +1236,7 @@ impl Function {
12341236
}
12351237

12361238
for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) {
1237-
sink.push(diag)
1239+
acc.push(diag.into())
12381240
}
12391241
acc
12401242
}

crates/hir_ty/src/diagnostics.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ impl fmt::Display for IdentType {
8484
}
8585
}
8686

87-
// Diagnostic: incorrect-ident-case
88-
//
89-
// This diagnostic is triggered if an item name doesn't follow https://doc.rust-lang.org/1.0.0/style/style/naming/README.html[Rust naming convention].
9087
#[derive(Debug)]
9188
pub struct IncorrectCase {
9289
pub file: HirFileId,

0 commit comments

Comments
 (0)