Skip to content

Commit 2a20e77

Browse files
committed
Add descriptions for diagnostics parseable by xtask
1 parent 52b19c3 commit 2a20e77

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

crates/hir_def/src/diagnostics.rs

+9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ use syntax::{ast, AstPtr, SyntaxNodePtr};
77

88
use hir_expand::{HirFileId, InFile};
99

10+
// Diagnostic: unresolved-module
11+
//
12+
// This diagnostic is triggered if rust-analyzer is unable to discover referred module.
1013
#[derive(Debug)]
1114
pub struct UnresolvedModule {
1215
pub file: HirFileId,
@@ -29,6 +32,9 @@ impl Diagnostic for UnresolvedModule {
2932
}
3033
}
3134

35+
// Diagnostic: unresolved-extern-crate
36+
//
37+
// This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate.
3238
#[derive(Debug)]
3339
pub struct UnresolvedExternCrate {
3440
pub file: HirFileId,
@@ -50,6 +56,9 @@ impl Diagnostic for UnresolvedExternCrate {
5056
}
5157
}
5258

59+
// Diagnostic: unresolved-import
60+
//
61+
// This diagnostic is triggered if rust-analyzer is unable to discover imported module.
5362
#[derive(Debug)]
5463
pub struct UnresolvedImport {
5564
pub file: HirFileId,

crates/hir_ty/src/diagnostics.rs

+55
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut Diag
3636
validator.validate_body(db);
3737
}
3838

39+
// Diagnostic: no-such-field
40+
//
41+
// This diagnostic is triggered if created structure does not have field provided in record.
3942
#[derive(Debug)]
4043
pub struct NoSuchField {
4144
pub file: HirFileId,
@@ -60,6 +63,17 @@ impl Diagnostic for NoSuchField {
6063
}
6164
}
6265

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+
// ```
6377
#[derive(Debug)]
6478
pub struct MissingFields {
6579
pub file: HirFileId,
@@ -96,6 +110,21 @@ impl Diagnostic for MissingFields {
96110
}
97111
}
98112

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+
// ```
99128
#[derive(Debug)]
100129
pub struct MissingPatFields {
101130
pub file: HirFileId,
@@ -130,6 +159,9 @@ impl Diagnostic for MissingPatFields {
130159
}
131160
}
132161

162+
// Diagnostic: missing-match-arm
163+
//
164+
// This diagnostic is triggered if `match` block is missing one or more match arms.
133165
#[derive(Debug)]
134166
pub struct MissingMatchArms {
135167
pub file: HirFileId,
@@ -152,6 +184,17 @@ impl Diagnostic for MissingMatchArms {
152184
}
153185
}
154186

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+
// ```
155198
#[derive(Debug)]
156199
pub struct MissingOkInTailExpr {
157200
pub file: HirFileId,
@@ -173,6 +216,9 @@ impl Diagnostic for MissingOkInTailExpr {
173216
}
174217
}
175218

219+
// Diagnostic: break-outside-of-loop
220+
//
221+
// This diagnostic is triggered if `break` keyword is used outside of a loop.
176222
#[derive(Debug)]
177223
pub struct BreakOutsideOfLoop {
178224
pub file: HirFileId,
@@ -194,6 +240,9 @@ impl Diagnostic for BreakOutsideOfLoop {
194240
}
195241
}
196242

243+
// Diagnostic: missing-unsafe
244+
//
245+
// This diagnostic is triggered if operation marked as `unsafe` is used outside of `unsafe` function or block.
197246
#[derive(Debug)]
198247
pub struct MissingUnsafe {
199248
pub file: HirFileId,
@@ -215,6 +264,9 @@ impl Diagnostic for MissingUnsafe {
215264
}
216265
}
217266

267+
// Diagnostic: mismatched-arg-count
268+
//
269+
// This diagnostic is triggered if function is invoked with an incorrect amount of arguments.
218270
#[derive(Debug)]
219271
pub struct MismatchedArgCount {
220272
pub file: HirFileId,
@@ -264,6 +316,9 @@ impl fmt::Display for CaseType {
264316
}
265317
}
266318

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].
267322
#[derive(Debug)]
268323
pub struct IncorrectCase {
269324
pub file: HirFileId,

0 commit comments

Comments
 (0)