@@ -5,7 +5,7 @@ use ide_db::{base_db::FileId, source_change::SourceChange};
5
5
use syntax:: { ast, match_ast, AstNode , SyntaxNode } ;
6
6
use text_edit:: TextEdit ;
7
7
8
- use crate :: { fix, Diagnostic , Severity } ;
8
+ use crate :: { fix, Diagnostic , DiagnosticCode } ;
9
9
10
10
pub ( crate ) fn field_shorthand ( acc : & mut Vec < Diagnostic > , file_id : FileId , node : & SyntaxNode ) {
11
11
match_ast ! {
@@ -46,14 +46,17 @@ fn check_expr_field_shorthand(
46
46
47
47
let field_range = record_field. syntax ( ) . text_range ( ) ;
48
48
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
+ ) ] ) ) ,
57
60
) ;
58
61
}
59
62
}
@@ -87,14 +90,17 @@ fn check_pat_field_shorthand(
87
90
88
91
let field_range = record_pat_field. syntax ( ) . text_range ( ) ;
89
92
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
+ ) ] ) ) ,
98
104
) ;
99
105
}
100
106
}
0 commit comments