diff options
-rw-r--r-- | crates/hir_def/src/diagnostics.rs | 9 | ||||
-rw-r--r-- | crates/hir_ty/src/diagnostics.rs | 55 |
2 files changed, 64 insertions, 0 deletions
diff --git a/crates/hir_def/src/diagnostics.rs b/crates/hir_def/src/diagnostics.rs index 001b3c5db..fcfbbbad3 100644 --- a/crates/hir_def/src/diagnostics.rs +++ b/crates/hir_def/src/diagnostics.rs | |||
@@ -7,6 +7,9 @@ use syntax::{ast, AstPtr, SyntaxNodePtr}; | |||
7 | 7 | ||
8 | use hir_expand::{HirFileId, InFile}; | 8 | use hir_expand::{HirFileId, InFile}; |
9 | 9 | ||
10 | // Diagnostic: unresolved-module | ||
11 | // | ||
12 | // This diagnostic is triggered if rust-analyzer is unable to discover referred module. | ||
10 | #[derive(Debug)] | 13 | #[derive(Debug)] |
11 | pub struct UnresolvedModule { | 14 | pub struct UnresolvedModule { |
12 | pub file: HirFileId, | 15 | pub file: HirFileId, |
@@ -29,6 +32,9 @@ impl Diagnostic for UnresolvedModule { | |||
29 | } | 32 | } |
30 | } | 33 | } |
31 | 34 | ||
35 | // Diagnostic: unresolved-extern-crate | ||
36 | // | ||
37 | // This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate. | ||
32 | #[derive(Debug)] | 38 | #[derive(Debug)] |
33 | pub struct UnresolvedExternCrate { | 39 | pub struct UnresolvedExternCrate { |
34 | pub file: HirFileId, | 40 | pub file: HirFileId, |
@@ -50,6 +56,9 @@ impl Diagnostic for UnresolvedExternCrate { | |||
50 | } | 56 | } |
51 | } | 57 | } |
52 | 58 | ||
59 | // Diagnostic: unresolved-import | ||
60 | // | ||
61 | // This diagnostic is triggered if rust-analyzer is unable to discover imported module. | ||
53 | #[derive(Debug)] | 62 | #[derive(Debug)] |
54 | pub struct UnresolvedImport { | 63 | pub struct UnresolvedImport { |
55 | pub file: HirFileId, | 64 | pub file: HirFileId, |
diff --git a/crates/hir_ty/src/diagnostics.rs b/crates/hir_ty/src/diagnostics.rs index dfe98571e..b58fe0ed7 100644 --- a/crates/hir_ty/src/diagnostics.rs +++ b/crates/hir_ty/src/diagnostics.rs | |||
@@ -36,6 +36,9 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag | |||
36 | validator.validate_body(db); | 36 | validator.validate_body(db); |
37 | } | 37 | } |
38 | 38 | ||
39 | // Diagnostic: no-such-field | ||
40 | // | ||
41 | // This diagnostic is triggered if created structure does not have field provided in record. | ||
39 | #[derive(Debug)] | 42 | #[derive(Debug)] |
40 | pub struct NoSuchField { | 43 | pub struct NoSuchField { |
41 | pub file: HirFileId, | 44 | pub file: HirFileId, |
@@ -60,6 +63,17 @@ impl Diagnostic for NoSuchField { | |||
60 | } | 63 | } |
61 | } | 64 | } |
62 | 65 | ||
66 | // Diagnostic: missing-structure-fields | ||
67 | // | ||
68 | // This diagnostic is triggered if record lacks some fields that exist in the corresponding structure. | ||
69 | // | ||
70 | // Example: | ||
71 | // | ||
72 | // ```rust | ||
73 | // struct A { a: u8, b: u8 } | ||
74 | // | ||
75 | // let a = A { a: 10 }; | ||
76 | // ``` | ||
63 | #[derive(Debug)] | 77 | #[derive(Debug)] |
64 | pub struct MissingFields { | 78 | pub struct MissingFields { |
65 | pub file: HirFileId, | 79 | pub file: HirFileId, |
@@ -96,6 +110,21 @@ impl Diagnostic for MissingFields { | |||
96 | } | 110 | } |
97 | } | 111 | } |
98 | 112 | ||
113 | // Diagnostic: missing-pat-fields | ||
114 | // | ||
115 | // This diagnostic is triggered if pattern lacks some fields that exist in the corresponding structure. | ||
116 | // | ||
117 | // Example: | ||
118 | // | ||
119 | // ```rust | ||
120 | // struct A { a: u8, b: u8 } | ||
121 | // | ||
122 | // let a = A { a: 10, b: 20 }; | ||
123 | // | ||
124 | // if let A { a } = a { | ||
125 | // // ... | ||
126 | // } | ||
127 | // ``` | ||
99 | #[derive(Debug)] | 128 | #[derive(Debug)] |
100 | pub struct MissingPatFields { | 129 | pub struct MissingPatFields { |
101 | pub file: HirFileId, | 130 | pub file: HirFileId, |
@@ -130,6 +159,9 @@ impl Diagnostic for MissingPatFields { | |||
130 | } | 159 | } |
131 | } | 160 | } |
132 | 161 | ||
162 | // Diagnostic: missing-match-arm | ||
163 | // | ||
164 | // This diagnostic is triggered if `match` block is missing one or more match arms. | ||
133 | #[derive(Debug)] | 165 | #[derive(Debug)] |
134 | pub struct MissingMatchArms { | 166 | pub struct MissingMatchArms { |
135 | pub file: HirFileId, | 167 | pub file: HirFileId, |
@@ -152,6 +184,17 @@ impl Diagnostic for MissingMatchArms { | |||
152 | } | 184 | } |
153 | } | 185 | } |
154 | 186 | ||
187 | // Diagnostic: missing-ok-in-tail-expr | ||
188 | // | ||
189 | // This diagnostic is triggered if block that should return `Result` returns a value not wrapped in `Ok`. | ||
190 | // | ||
191 | // Example: | ||
192 | // | ||
193 | // ```rust | ||
194 | // fn foo() -> Result<u8, ()> { | ||
195 | // 10 | ||
196 | // } | ||
197 | // ``` | ||
155 | #[derive(Debug)] | 198 | #[derive(Debug)] |
156 | pub struct MissingOkInTailExpr { | 199 | pub struct MissingOkInTailExpr { |
157 | pub file: HirFileId, | 200 | pub file: HirFileId, |
@@ -173,6 +216,9 @@ impl Diagnostic for MissingOkInTailExpr { | |||
173 | } | 216 | } |
174 | } | 217 | } |
175 | 218 | ||
219 | // Diagnostic: break-outside-of-loop | ||
220 | // | ||
221 | // This diagnostic is triggered if `break` keyword is used outside of a loop. | ||
176 | #[derive(Debug)] | 222 | #[derive(Debug)] |
177 | pub struct BreakOutsideOfLoop { | 223 | pub struct BreakOutsideOfLoop { |
178 | pub file: HirFileId, | 224 | pub file: HirFileId, |
@@ -194,6 +240,9 @@ impl Diagnostic for BreakOutsideOfLoop { | |||
194 | } | 240 | } |
195 | } | 241 | } |
196 | 242 | ||
243 | // Diagnostic: missing-unsafe | ||
244 | // | ||
245 | // This diagnostic is triggered if operation marked as `unsafe` is used outside of `unsafe` function or block. | ||
197 | #[derive(Debug)] | 246 | #[derive(Debug)] |
198 | pub struct MissingUnsafe { | 247 | pub struct MissingUnsafe { |
199 | pub file: HirFileId, | 248 | pub file: HirFileId, |
@@ -215,6 +264,9 @@ impl Diagnostic for MissingUnsafe { | |||
215 | } | 264 | } |
216 | } | 265 | } |
217 | 266 | ||
267 | // Diagnostic: mismatched-arg-count | ||
268 | // | ||
269 | // This diagnostic is triggered if function is invoked with an incorrect amount of arguments. | ||
218 | #[derive(Debug)] | 270 | #[derive(Debug)] |
219 | pub struct MismatchedArgCount { | 271 | pub struct MismatchedArgCount { |
220 | pub file: HirFileId, | 272 | pub file: HirFileId, |
@@ -264,6 +316,9 @@ impl fmt::Display for CaseType { | |||
264 | } | 316 | } |
265 | } | 317 | } |
266 | 318 | ||
319 | // Diagnostic: incorrect-ident-case | ||
320 | // | ||
321 | // This diagnostic is triggered if item name doesn't follow https://doc.rust-lang.org/1.0.0/style/style/naming/README.html[Rust naming convention]. | ||
267 | #[derive(Debug)] | 322 | #[derive(Debug)] |
268 | pub struct IncorrectCase { | 323 | pub struct IncorrectCase { |
269 | pub file: HirFileId, | 324 | pub file: HirFileId, |