diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-06-13 19:34:32 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-13 19:34:32 +0100 |
commit | 76530664e7f01091e0d820eb49bf59db1f06115c (patch) | |
tree | 9700c178acb48fcc029f4120169f00a94d7308f0 /crates/hir/src | |
parent | 2ad78924621420cb323efdeb3d875ca3f47d940f (diff) | |
parent | 3478897f86cc1b3e3f83e9d4e7cedff41721fb04 (diff) |
Merge #9255
9255: internal: remove DiagnosticWithFix infra r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir/src')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 29 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 18 |
2 files changed, 11 insertions, 36 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index c294a803b..c2d608eb5 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -34,6 +34,7 @@ macro_rules! diagnostics { | |||
34 | diagnostics![ | 34 | diagnostics![ |
35 | BreakOutsideOfLoop, | 35 | BreakOutsideOfLoop, |
36 | InactiveCode, | 36 | InactiveCode, |
37 | IncorrectCase, | ||
37 | MacroError, | 38 | MacroError, |
38 | MismatchedArgCount, | 39 | MismatchedArgCount, |
39 | MissingFields, | 40 | MissingFields, |
@@ -195,31 +196,3 @@ impl Diagnostic for InternalBailedOut { | |||
195 | } | 196 | } |
196 | 197 | ||
197 | pub use hir_ty::diagnostics::IncorrectCase; | 198 | 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 | } | ||
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index b2731b62f..fc147ade3 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -86,8 +86,8 @@ use crate::{ | |||
86 | pub use crate::{ | 86 | pub use crate::{ |
87 | attrs::{HasAttrs, Namespace}, | 87 | attrs::{HasAttrs, Namespace}, |
88 | diagnostics::{ | 88 | diagnostics::{ |
89 | AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, InternalBailedOut, MacroError, | 89 | AnyDiagnostic, BreakOutsideOfLoop, InactiveCode, IncorrectCase, InternalBailedOut, |
90 | MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, | 90 | MacroError, MismatchedArgCount, MissingFields, MissingMatchArms, MissingOkOrSomeInTailExpr, |
91 | MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap, | 91 | MissingUnsafe, NoSuchField, RemoveThisSemicolon, ReplaceFilterMapNextWithFindMap, |
92 | UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, | 92 | UnimplementedBuiltinMacro, UnresolvedExternCrate, UnresolvedImport, UnresolvedMacroCall, |
93 | UnresolvedModule, UnresolvedProcMacro, | 93 | UnresolvedModule, UnresolvedProcMacro, |
@@ -340,7 +340,7 @@ impl ModuleDef { | |||
340 | } | 340 | } |
341 | } | 341 | } |
342 | 342 | ||
343 | pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { | 343 | pub fn diagnostics(self, db: &dyn HirDatabase) -> Vec<AnyDiagnostic> { |
344 | let id = match self { | 344 | let id = match self { |
345 | ModuleDef::Adt(it) => match it { | 345 | ModuleDef::Adt(it) => match it { |
346 | Adt::Struct(it) => it.id.into(), | 346 | Adt::Struct(it) => it.id.into(), |
@@ -353,17 +353,19 @@ impl ModuleDef { | |||
353 | ModuleDef::Module(it) => it.id.into(), | 353 | ModuleDef::Module(it) => it.id.into(), |
354 | ModuleDef::Const(it) => it.id.into(), | 354 | ModuleDef::Const(it) => it.id.into(), |
355 | ModuleDef::Static(it) => it.id.into(), | 355 | ModuleDef::Static(it) => it.id.into(), |
356 | _ => return, | 356 | _ => return Vec::new(), |
357 | }; | 357 | }; |
358 | 358 | ||
359 | let module = match self.module(db) { | 359 | let module = match self.module(db) { |
360 | Some(it) => it, | 360 | Some(it) => it, |
361 | None => return, | 361 | None => return Vec::new(), |
362 | }; | 362 | }; |
363 | 363 | ||
364 | let mut acc = Vec::new(); | ||
364 | for diag in hir_ty::diagnostics::validate_module_item(db, module.id.krate(), id) { | 365 | for diag in hir_ty::diagnostics::validate_module_item(db, module.id.krate(), id) { |
365 | sink.push(diag) | 366 | acc.push(diag.into()) |
366 | } | 367 | } |
368 | acc | ||
367 | } | 369 | } |
368 | } | 370 | } |
369 | 371 | ||
@@ -624,7 +626,7 @@ impl Module { | |||
624 | acc.extend(m.diagnostics(db, sink, internal_diagnostics)) | 626 | acc.extend(m.diagnostics(db, sink, internal_diagnostics)) |
625 | } | 627 | } |
626 | } | 628 | } |
627 | _ => decl.diagnostics(db, sink), | 629 | _ => acc.extend(decl.diagnostics(db)), |
628 | } | 630 | } |
629 | } | 631 | } |
630 | 632 | ||
@@ -1234,7 +1236,7 @@ impl Function { | |||
1234 | } | 1236 | } |
1235 | 1237 | ||
1236 | for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) { | 1238 | for diag in hir_ty::diagnostics::validate_module_item(db, krate, self.id.into()) { |
1237 | sink.push(diag) | 1239 | acc.push(diag.into()) |
1238 | } | 1240 | } |
1239 | acc | 1241 | acc |
1240 | } | 1242 | } |