Skip to content

Commit

Permalink
BE: Simplify expected_type code
Browse files Browse the repository at this point in the history
Summary: Use the `SpecBody` now stored in `FunctionBody` when working with type mismatches.

Reviewed By: robertoaloi

Differential Revision: D55022168

fbshipit-source-id: 514c2712fd58344675d2d65f28577fb1810fbf30
  • Loading branch information
alanz authored and facebook-github-bot committed Mar 20, 2024
1 parent 93ae1ef commit 56a26a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/ide/src/diagnostics/eqwalizer_assists/expected_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use elp_types_db::eqwalizer::StructuredDiagnostic;
use hir::InFile;
use hir::Literal;
use hir::Semantic;
use hir::SpecBody;
use hir::TypeExpr;
use text_edit::TextEdit;

Expand Down Expand Up @@ -69,10 +70,9 @@ fn add_spec_fix(
},
)?;
let function_id = sema.find_enclosing_function(file_id, &token.value.parent()?)?;
let def_map = sema.def_map(file_id);
let function_def = def_map.get_by_function_id(&InFile::new(file_id, function_id))?;
let spec_id = InFile::new(file_id, function_def.spec.clone()?.spec_id);
let spec_body = sema.db.spec_body(spec_id);
let function = sema.db.function_body(InFile::new(file_id, function_id));
let spec_body: &SpecBody = function.spec_body()?;
let spec_id = InFile::new(file_id, spec_body.spec_id()?);
// We are looking for a single spec signature with a single atom return type.
match &spec_body.sigs[..] {
[sig] => {
Expand Down

0 comments on commit 56a26a5

Please sign in to comment.