aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/diagnostics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/diagnostics.rs')
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 3623b8569..3016ca3bd 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -244,3 +244,28 @@ impl AstDiagnostic for MismatchedArgCount {
244 ast::CallExpr::cast(node).unwrap() 244 ast::CallExpr::cast(node).unwrap()
245 } 245 }
246} 246}
247
248#[cfg(test)]
249fn check_diagnostics(ra_fixture: &str) {
250 use ra_db::{fixture::WithFixture, FileId};
251 use ra_syntax::TextRange;
252 use rustc_hash::FxHashMap;
253
254 use crate::test_db::TestDB;
255
256 let db = TestDB::with_files(ra_fixture);
257 let annotations = db.extract_annotations();
258
259 let mut actual: FxHashMap<FileId, Vec<(TextRange, String)>> = FxHashMap::default();
260 db.diag(|d| {
261 // FXIME: macros...
262 let file_id = d.source().file_id.original_file(&db);
263 let range = d.syntax_node(&db).text_range();
264 // FIXME: support multi-line messages in annotations
265 let message = d.message().lines().next().unwrap().to_owned();
266 actual.entry(file_id).or_default().push((range, message));
267 });
268 actual.values_mut().for_each(|diags| diags.sort_by_key(|it| it.0.start()));
269
270 assert_eq!(annotations, actual);
271}