From 2a20e7795cc853fd335dcf64b893693514f62bb3 Mon Sep 17 00:00:00 2001 From: Igor Aleksanov Date: Sat, 17 Oct 2020 17:29:06 +0300 Subject: Add descriptions for diagnostics parseable by xtask --- crates/hir_def/src/diagnostics.rs | 9 +++++++ crates/hir_ty/src/diagnostics.rs | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'crates') 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}; use hir_expand::{HirFileId, InFile}; +// Diagnostic: unresolved-module +// +// This diagnostic is triggered if rust-analyzer is unable to discover referred module. #[derive(Debug)] pub struct UnresolvedModule { pub file: HirFileId, @@ -29,6 +32,9 @@ impl Diagnostic for UnresolvedModule { } } +// Diagnostic: unresolved-extern-crate +// +// This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate. #[derive(Debug)] pub struct UnresolvedExternCrate { pub file: HirFileId, @@ -50,6 +56,9 @@ impl Diagnostic for UnresolvedExternCrate { } } +// Diagnostic: unresolved-import +// +// This diagnostic is triggered if rust-analyzer is unable to discover imported module. #[derive(Debug)] pub struct UnresolvedImport { 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 validator.validate_body(db); } +// Diagnostic: no-such-field +// +// This diagnostic is triggered if created structure does not have field provided in record. #[derive(Debug)] pub struct NoSuchField { pub file: HirFileId, @@ -60,6 +63,17 @@ impl Diagnostic for NoSuchField { } } +// Diagnostic: missing-structure-fields +// +// This diagnostic is triggered if record lacks some fields that exist in the corresponding structure. +// +// Example: +// +// ```rust +// struct A { a: u8, b: u8 } +// +// let a = A { a: 10 }; +// ``` #[derive(Debug)] pub struct MissingFields { pub file: HirFileId, @@ -96,6 +110,21 @@ impl Diagnostic for MissingFields { } } +// Diagnostic: missing-pat-fields +// +// This diagnostic is triggered if pattern lacks some fields that exist in the corresponding structure. +// +// Example: +// +// ```rust +// struct A { a: u8, b: u8 } +// +// let a = A { a: 10, b: 20 }; +// +// if let A { a } = a { +// // ... +// } +// ``` #[derive(Debug)] pub struct MissingPatFields { pub file: HirFileId, @@ -130,6 +159,9 @@ impl Diagnostic for MissingPatFields { } } +// Diagnostic: missing-match-arm +// +// This diagnostic is triggered if `match` block is missing one or more match arms. #[derive(Debug)] pub struct MissingMatchArms { pub file: HirFileId, @@ -152,6 +184,17 @@ impl Diagnostic for MissingMatchArms { } } +// Diagnostic: missing-ok-in-tail-expr +// +// This diagnostic is triggered if block that should return `Result` returns a value not wrapped in `Ok`. +// +// Example: +// +// ```rust +// fn foo() -> Result { +// 10 +// } +// ``` #[derive(Debug)] pub struct MissingOkInTailExpr { pub file: HirFileId, @@ -173,6 +216,9 @@ impl Diagnostic for MissingOkInTailExpr { } } +// Diagnostic: break-outside-of-loop +// +// This diagnostic is triggered if `break` keyword is used outside of a loop. #[derive(Debug)] pub struct BreakOutsideOfLoop { pub file: HirFileId, @@ -194,6 +240,9 @@ impl Diagnostic for BreakOutsideOfLoop { } } +// Diagnostic: missing-unsafe +// +// This diagnostic is triggered if operation marked as `unsafe` is used outside of `unsafe` function or block. #[derive(Debug)] pub struct MissingUnsafe { pub file: HirFileId, @@ -215,6 +264,9 @@ impl Diagnostic for MissingUnsafe { } } +// Diagnostic: mismatched-arg-count +// +// This diagnostic is triggered if function is invoked with an incorrect amount of arguments. #[derive(Debug)] pub struct MismatchedArgCount { pub file: HirFileId, @@ -264,6 +316,9 @@ impl fmt::Display for CaseType { } } +// Diagnostic: incorrect-ident-case +// +// 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]. #[derive(Debug)] pub struct IncorrectCase { pub file: HirFileId, -- cgit v1.2.3