From b37c6a746b6c7cf85dc1ec6e40ac41455b8f2ec0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 8 Dec 2019 12:44:14 +0100 Subject: Remove ty from code_model --- crates/ra_cli/src/analysis_stats.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'crates/ra_cli/src/analysis_stats.rs') diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index 9b1802a5f..ac65415a5 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs @@ -2,8 +2,13 @@ use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; +use hir::{ + db::{DefDatabase, HirDatabase}, + AssocItem, Crate, HasSource, HirDisplay, ModuleDef, +}; +use hir_def::FunctionId; +use hir_ty::{Ty, TypeWalk}; use ra_db::SourceDatabaseExt; -use ra_hir::{AssocItem, Crate, HasSource, HirDisplay, ModuleDef, Ty, TypeWalk}; use ra_syntax::AstNode; use crate::{progress_report::ProgressReport, Result, Verbosity}; @@ -101,8 +106,9 @@ pub fn run( continue; } } - let body = f.body(db); - let inference_result = f.infer(db); + let f_id = FunctionId::from(f); + let body = db.body(f_id.into()); + let inference_result = db.infer(f_id.into()); for (expr_id, _) in body.exprs.iter() { let ty = &inference_result[expr_id]; num_exprs += 1; @@ -122,7 +128,8 @@ pub fn run( if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) { num_type_mismatches += 1; if verbosity.is_verbose() { - let src = f.body_source_map(db).expr_syntax(expr_id); + let (_, sm) = db.body_with_source_map(f_id.into()); + let src = sm.expr_syntax(expr_id); if let Some(src) = src { // FIXME: it might be nice to have a function (on Analysis?) that goes from Source -> (LineCol, LineCol) directly let original_file = src.file_id.original_file(db); -- cgit v1.2.3