aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty')
-rw-r--r--crates/hir_ty/src/diagnostics.rs55
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)]
40pub struct NoSuchField { 43pub 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)]
64pub struct MissingFields { 78pub 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)]
100pub struct MissingPatFields { 129pub 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)]
134pub struct MissingMatchArms { 166pub 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)]
156pub struct MissingOkInTailExpr { 199pub 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)]
177pub struct BreakOutsideOfLoop { 223pub 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)]
198pub struct MissingUnsafe { 247pub 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)]
219pub struct MismatchedArgCount { 271pub 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)]
268pub struct IncorrectCase { 323pub struct IncorrectCase {
269 pub file: HirFileId, 324 pub file: HirFileId,