diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-10-20 10:46:43 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-10-20 10:46:43 +0100 |
commit | 4c00bdea675d33d578cff1c0d7cc3967303e6653 (patch) | |
tree | bc1cd5b714e9566e2c87f33582d8c587cf46f6c0 /crates/hir_ty | |
parent | 378dd90bab65fa6df078444c3932118105a460b8 (diff) | |
parent | b8a74e03708819c04862005ad0a91757dd63d654 (diff) |
Merge #6266
6266: Generate diagnostics docs r=matklad a=popzxc
Resolves #6215
Co-authored-by: Igor Aleksanov <[email protected]>
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/diagnostics.rs | 55 |
1 files changed, 55 insertions, 0 deletions
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, |