mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Merge #5682
5682: Add an option to disable diagnostics r=matklad a=popzxc As far as I know, currently it's not possible to disable a selected type of diagnostics provided by `rust-analyzer`. This causes an inconvenient situation with a false-positive warnings: you either have to disable all the diagnostics, or you have to ignore these warnings. There are some open issues related to this problem, e.g.: https://github.com/rust-analyzer/rust-analyzer/issues/5412, https://github.com/rust-analyzer/rust-analyzer/issues/5502 This PR attempts to make it possible to selectively disable some diagnostics on per-project basis. Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
This commit is contained in:
commit
b8dfc331ab
10 changed files with 155 additions and 15 deletions
|
@ -32,6 +32,10 @@ pub struct NoSuchField {
|
|||
}
|
||||
|
||||
impl Diagnostic for NoSuchField {
|
||||
fn name(&self) -> &'static str {
|
||||
"no-such-field"
|
||||
}
|
||||
|
||||
fn message(&self) -> String {
|
||||
"no such field".to_string()
|
||||
}
|
||||
|
@ -54,6 +58,9 @@ pub struct MissingFields {
|
|||
}
|
||||
|
||||
impl Diagnostic for MissingFields {
|
||||
fn name(&self) -> &'static str {
|
||||
"missing-structure-fields"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
let mut buf = String::from("Missing structure fields:\n");
|
||||
for field in &self.missed_fields {
|
||||
|
@ -87,6 +94,9 @@ pub struct MissingPatFields {
|
|||
}
|
||||
|
||||
impl Diagnostic for MissingPatFields {
|
||||
fn name(&self) -> &'static str {
|
||||
"missing-pat-fields"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
let mut buf = String::from("Missing structure fields:\n");
|
||||
for field in &self.missed_fields {
|
||||
|
@ -117,6 +127,9 @@ pub struct MissingMatchArms {
|
|||
}
|
||||
|
||||
impl Diagnostic for MissingMatchArms {
|
||||
fn name(&self) -> &'static str {
|
||||
"missing-match-arm"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
String::from("Missing match arm")
|
||||
}
|
||||
|
@ -135,6 +148,9 @@ pub struct MissingOkInTailExpr {
|
|||
}
|
||||
|
||||
impl Diagnostic for MissingOkInTailExpr {
|
||||
fn name(&self) -> &'static str {
|
||||
"missing-ok-in-tail-expr"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
"wrap return expression in Ok".to_string()
|
||||
}
|
||||
|
@ -153,6 +169,9 @@ pub struct BreakOutsideOfLoop {
|
|||
}
|
||||
|
||||
impl Diagnostic for BreakOutsideOfLoop {
|
||||
fn name(&self) -> &'static str {
|
||||
"break-outside-of-loop"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
"break outside of loop".to_string()
|
||||
}
|
||||
|
@ -171,6 +190,9 @@ pub struct MissingUnsafe {
|
|||
}
|
||||
|
||||
impl Diagnostic for MissingUnsafe {
|
||||
fn name(&self) -> &'static str {
|
||||
"missing-unsafe"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
format!("This operation is unsafe and requires an unsafe function or block")
|
||||
}
|
||||
|
@ -191,6 +213,9 @@ pub struct MismatchedArgCount {
|
|||
}
|
||||
|
||||
impl Diagnostic for MismatchedArgCount {
|
||||
fn name(&self) -> &'static str {
|
||||
"mismatched-arg-count"
|
||||
}
|
||||
fn message(&self) -> String {
|
||||
let s = if self.expected == 1 { "" } else { "s" };
|
||||
format!("Expected {} argument{}, found {}", self.expected, s, self.found)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue