@@ -5,7 +5,7 @@ use ide_db::{base_db::FileId, source_change::SourceChange};
55use syntax:: { ast, match_ast, AstNode , SyntaxNode } ;
66use text_edit:: TextEdit ;
77
8- use crate :: { fix, Diagnostic , Severity } ;
8+ use crate :: { fix, Diagnostic , DiagnosticCode } ;
99
1010pub ( crate ) fn field_shorthand ( acc : & mut Vec < Diagnostic > , file_id : FileId , node : & SyntaxNode ) {
1111 match_ast ! {
@@ -46,14 +46,17 @@ fn check_expr_field_shorthand(
4646
4747 let field_range = record_field. syntax ( ) . text_range ( ) ;
4848 acc. push (
49- Diagnostic :: new ( "use-field-shorthand" , "Shorthand struct initialization" , field_range)
50- . severity ( Severity :: WeakWarning )
51- . with_fixes ( Some ( vec ! [ fix(
52- "use_expr_field_shorthand" ,
53- "Use struct shorthand initialization" ,
54- SourceChange :: from_text_edit( file_id, edit) ,
55- field_range,
56- ) ] ) ) ,
49+ Diagnostic :: new (
50+ DiagnosticCode :: Clippy ( "redundant_field_names" ) ,
51+ "Shorthand struct initialization" ,
52+ field_range,
53+ )
54+ . with_fixes ( Some ( vec ! [ fix(
55+ "use_expr_field_shorthand" ,
56+ "Use struct shorthand initialization" ,
57+ SourceChange :: from_text_edit( file_id, edit) ,
58+ field_range,
59+ ) ] ) ) ,
5760 ) ;
5861 }
5962}
@@ -87,14 +90,17 @@ fn check_pat_field_shorthand(
8790
8891 let field_range = record_pat_field. syntax ( ) . text_range ( ) ;
8992 acc. push (
90- Diagnostic :: new ( "use-field-shorthand" , "Shorthand struct pattern" , field_range)
91- . severity ( Severity :: WeakWarning )
92- . with_fixes ( Some ( vec ! [ fix(
93- "use_pat_field_shorthand" ,
94- "Use struct field shorthand" ,
95- SourceChange :: from_text_edit( file_id, edit) ,
96- field_range,
97- ) ] ) ) ,
93+ Diagnostic :: new (
94+ DiagnosticCode :: Clippy ( "redundant_field_names" ) ,
95+ "Shorthand struct pattern" ,
96+ field_range,
97+ )
98+ . with_fixes ( Some ( vec ! [ fix(
99+ "use_pat_field_shorthand" ,
100+ "Use struct field shorthand" ,
101+ SourceChange :: from_text_edit( file_id, edit) ,
102+ field_range,
103+ ) ] ) ) ,
98104 ) ;
99105 }
100106}
0 commit comments