6775: Fix MissingFields DiagnosticFix trigger range r=lnicola a=Veykril

Fixes #5950

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2020-12-09 12:12:43 +00:00 committed by GitHub
commit 8fbaa8e495
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,8 @@ fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> {
}
let root = sema.db.parse_or_expand(self.file)?;
let old_field_list = self.field_list_parent.to_node(&root).record_expr_field_list()?;
let field_list_parent = self.field_list_parent.to_node(&root);
let old_field_list = field_list_parent.record_expr_field_list()?;
let mut new_field_list = old_field_list.clone();
for f in self.missed_fields.iter() {
let field =
@ -85,7 +86,7 @@ fn fix(&self, sema: &Semantics<RootDatabase>) -> Option<Fix> {
Some(Fix::new(
"Fill struct fields",
SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(),
sema.original_range(&old_field_list.syntax()).range,
sema.original_range(&field_list_parent.syntax()).range,
))
}
}