aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cli
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-08-25 18:28:32 +0100
committerFlorian Diebold <[email protected]>2019-09-02 13:56:38 +0100
commita7858bb7bf0a784d56b2b9ef97785a4fa78f7853 (patch)
treeffc29db397d35b9cfa55d2418db996dbf22e4995 /crates/ra_cli
parent6ecb36740a81445cf103577c3f9e9e6f831d0a1b (diff)
Report type mismatches in analysis-stats
Only the number usually; each one individually when running with -v.
Diffstat (limited to 'crates/ra_cli')
-rw-r--r--crates/ra_cli/src/analysis_stats.rs38
1 files changed, 37 insertions, 1 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs
index 7e7e6c073..77fa1d26e 100644
--- a/crates/ra_cli/src/analysis_stats.rs
+++ b/crates/ra_cli/src/analysis_stats.rs
@@ -1,7 +1,7 @@
1use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; 1use std::{collections::HashSet, fmt::Write, path::Path, time::Instant};
2 2
3use ra_db::SourceDatabase; 3use ra_db::SourceDatabase;
4use ra_hir::{Crate, HasSource, ImplItem, ModuleDef, Ty}; 4use ra_hir::{Crate, HasSource, HirDisplay, ImplItem, ModuleDef, Ty};
5use ra_syntax::AstNode; 5use ra_syntax::AstNode;
6 6
7use crate::Result; 7use crate::Result;
@@ -66,6 +66,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -
66 let mut num_exprs = 0; 66 let mut num_exprs = 0;
67 let mut num_exprs_unknown = 0; 67 let mut num_exprs_unknown = 0;
68 let mut num_exprs_partially_unknown = 0; 68 let mut num_exprs_partially_unknown = 0;
69 let mut num_type_mismatches = 0;
69 for f in funcs { 70 for f in funcs {
70 let name = f.name(db); 71 let name = f.name(db);
71 let mut msg = format!("processing: {}", name); 72 let mut msg = format!("processing: {}", name);
@@ -100,6 +101,40 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -
100 num_exprs_partially_unknown += 1; 101 num_exprs_partially_unknown += 1;
101 } 102 }
102 } 103 }
104 if let Some(mismatch) = inference_result.type_mismatch_for_expr(expr_id) {
105 num_type_mismatches += 1;
106 if verbose {
107 let src = f.source(db);
108 let original_file = src.file_id.original_file(db);
109 let path = db.file_relative_path(original_file);
110 let line_index = host.analysis().file_line_index(original_file).unwrap();
111 let body_source_map = f.body_source_map(db);
112 let syntax_node = body_source_map.expr_syntax(expr_id);
113 let line_col = syntax_node.map(|syntax_node| {
114 (
115 line_index.line_col(syntax_node.range().start()),
116 line_index.line_col(syntax_node.range().end()),
117 )
118 });
119 let line_col = match line_col {
120 Some((start, end)) => format!(
121 "{}:{}-{}:{}",
122 start.line + 1,
123 start.col_utf16,
124 end.line + 1,
125 end.col_utf16
126 ),
127 None => "?:?".to_string(),
128 };
129 bar.println(format!(
130 "{} {}: Expected {}, got {}",
131 path.display(),
132 line_col,
133 mismatch.expected.display(db),
134 mismatch.actual.display(db)
135 ));
136 }
137 }
103 } 138 }
104 bar.inc(1); 139 bar.inc(1);
105 } 140 }
@@ -115,6 +150,7 @@ pub fn run(verbose: bool, memory_usage: bool, path: &Path, only: Option<&str>) -
115 num_exprs_partially_unknown, 150 num_exprs_partially_unknown,
116 (num_exprs_partially_unknown * 100 / num_exprs) 151 (num_exprs_partially_unknown * 100 / num_exprs)
117 ); 152 );
153 println!("Type mismatches: {}", num_type_mismatches);
118 println!("Inference: {:?}, {}", inference_time.elapsed(), ra_prof::memory_usage()); 154 println!("Inference: {:?}, {}", inference_time.elapsed(), ra_prof::memory_usage());
119 println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage()); 155 println!("Total: {:?}, {}", analysis_time.elapsed(), ra_prof::memory_usage());
120 156