11use std:: cell:: RefCell ;
22
33use hir:: {
4- diagnostics:: { Diagnostic as _, DiagnosticSink } ,
4+ diagnostics:: { AstDiagnostic , Diagnostic as _, DiagnosticSink } ,
55 source_binder,
66} ;
77use itertools:: Itertools ;
88use ra_assists:: ast_editor:: { AstBuilder , AstEditor } ;
99use ra_db:: SourceDatabase ;
1010use ra_prof:: profile;
1111use ra_syntax:: {
12- ast:: { self , AstNode , NamedField , NamedFieldList } ,
12+ ast:: { self , AstNode , NamedField } ,
1313 Location , SyntaxNode , TextRange , T ,
1414} ;
1515use ra_text_edit:: { TextEdit , TextEditBuilder } ;
@@ -34,9 +34,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
3434 fix : None ,
3535 } ) ) ;
3636
37- let source_file = parse. tree ;
38-
39- for node in source_file. syntax ( ) . descendants ( ) {
37+ for node in parse. tree . syntax ( ) . descendants ( ) {
4038 check_unnecessary_braces_in_use_statement ( & mut res, file_id, node) ;
4139 check_struct_shorthand_initialization ( & mut res, file_id, node) ;
4240 }
@@ -61,9 +59,8 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
6159 } )
6260 } )
6361 . 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) ;
6764 for f in d. missed_fields . iter ( ) {
6865 ast_editor. append_field ( & AstBuilder :: < NamedField > :: from_name ( f) ) ;
6966 }
0 commit comments