1
1
use std:: cell:: RefCell ;
2
2
3
3
use hir:: {
4
- diagnostics:: { Diagnostic as _, DiagnosticSink } ,
4
+ diagnostics:: { AstDiagnostic , Diagnostic as _, DiagnosticSink } ,
5
5
source_binder,
6
6
} ;
7
7
use itertools:: Itertools ;
8
8
use ra_assists:: ast_editor:: { AstBuilder , AstEditor } ;
9
9
use ra_db:: SourceDatabase ;
10
10
use ra_prof:: profile;
11
11
use ra_syntax:: {
12
- ast:: { self , AstNode , NamedField , NamedFieldList } ,
12
+ ast:: { self , AstNode , NamedField } ,
13
13
Location , SyntaxNode , TextRange , T ,
14
14
} ;
15
15
use ra_text_edit:: { TextEdit , TextEditBuilder } ;
@@ -34,9 +34,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
34
34
fix : None ,
35
35
} ) ) ;
36
36
37
- let source_file = parse. tree ;
38
-
39
- for node in source_file. syntax ( ) . descendants ( ) {
37
+ for node in parse. tree . syntax ( ) . descendants ( ) {
40
38
check_unnecessary_braces_in_use_statement ( & mut res, file_id, node) ;
41
39
check_struct_shorthand_initialization ( & mut res, file_id, node) ;
42
40
}
@@ -61,9 +59,8 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
61
59
} )
62
60
} )
63
61
. on :: < hir:: diagnostics:: MissingFields , _ > ( |d| {
64
- let syntax_node = d. syntax_node_ptr ( ) ;
65
- let node = NamedFieldList :: cast ( syntax_node. to_node ( source_file. syntax ( ) ) ) . unwrap ( ) ;
66
- let mut ast_editor = AstEditor :: new ( node) ;
62
+ let node = d. ast ( db) ;
63
+ let mut ast_editor = AstEditor :: new ( & * node) ;
67
64
for f in d. missed_fields . iter ( ) {
68
65
ast_editor. append_field ( & AstBuilder :: < NamedField > :: from_name ( f) ) ;
69
66
}
0 commit comments