From a54e481646edb151075d12ca6903091abe7cfc4e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 20 Oct 2020 17:48:43 +0200 Subject: Simplify diagnostic construction, add unused field --- crates/ide/src/diagnostics/field_shorthand.rs | 32 +++++++++++---------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'crates/ide/src/diagnostics') diff --git a/crates/ide/src/diagnostics/field_shorthand.rs b/crates/ide/src/diagnostics/field_shorthand.rs index 2c4acd783..54e9fce9e 100644 --- a/crates/ide/src/diagnostics/field_shorthand.rs +++ b/crates/ide/src/diagnostics/field_shorthand.rs @@ -6,7 +6,7 @@ use ide_db::source_change::SourceFileEdit; use syntax::{ast, match_ast, AstNode, SyntaxNode}; use text_edit::TextEdit; -use crate::{Diagnostic, Fix, Severity}; +use crate::{Diagnostic, Fix}; pub(super) fn check(acc: &mut Vec, file_id: FileId, node: &SyntaxNode) { match_ast! { @@ -46,17 +46,15 @@ fn check_expr_field_shorthand( let edit = edit_builder.finish(); let field_range = record_field.syntax().text_range(); - acc.push(Diagnostic { - // name: None, - range: field_range, - message: "Shorthand struct initialization".to_string(), - severity: Severity::WeakWarning, - fix: Some(Fix::new( - "Use struct shorthand initialization", - SourceFileEdit { file_id, edit }.into(), - field_range, - )), - }); + acc.push( + Diagnostic::hint(field_range, "Shorthand struct initialization".to_string()).with_fix( + Some(Fix::new( + "Use struct shorthand initialization", + SourceFileEdit { file_id, edit }.into(), + field_range, + )), + ), + ); } } @@ -88,17 +86,13 @@ fn check_pat_field_shorthand( let edit = edit_builder.finish(); let field_range = record_pat_field.syntax().text_range(); - acc.push(Diagnostic { - // name: None, - range: field_range, - message: "Shorthand struct pattern".to_string(), - severity: Severity::WeakWarning, - fix: Some(Fix::new( + acc.push(Diagnostic::hint(field_range, "Shorthand struct pattern".to_string()).with_fix( + Some(Fix::new( "Use struct field shorthand", SourceFileEdit { file_id, edit }.into(), field_range, )), - }); + )); } } -- cgit v1.2.3