Fix panic in NoSuchField diagnostic

This commit is contained in:
Aleksey Kladov 2020-04-25 20:56:25 +02:00
parent 95b989ec30
commit 0f099ead88

View file

@ -667,7 +667,7 @@ impl Expectation {
} }
mod diagnostics { mod diagnostics {
use hir_def::{expr::ExprId, src::HasSource, FunctionId, Lookup}; use hir_def::{expr::ExprId, FunctionId};
use hir_expand::diagnostics::DiagnosticSink; use hir_expand::diagnostics::DiagnosticSink;
use crate::{db::HirDatabase, diagnostics::NoSuchField}; use crate::{db::HirDatabase, diagnostics::NoSuchField};
@ -686,10 +686,9 @@ mod diagnostics {
) { ) {
match self { match self {
InferenceDiagnostic::NoSuchField { expr, field } => { InferenceDiagnostic::NoSuchField { expr, field } => {
let source = owner.lookup(db.upcast()).source(db.upcast());
let (_, source_map) = db.body_with_source_map(owner.into()); let (_, source_map) = db.body_with_source_map(owner.into());
let field = source_map.field_syntax(*expr, *field); let field = source_map.field_syntax(*expr, *field);
sink.push(NoSuchField { file: source.file_id, field: field.value }) sink.push(NoSuchField { file: field.file_id, field: field.value })
} }
} }
} }