diff options
Diffstat (limited to 'crates/ra_hir_ty/src/diagnostics.rs')
-rw-r--r-- | crates/ra_hir_ty/src/diagnostics.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs index 3623b8569..49a616c6f 100644 --- a/crates/ra_hir_ty/src/diagnostics.rs +++ b/crates/ra_hir_ty/src/diagnostics.rs | |||
@@ -244,3 +244,25 @@ impl AstDiagnostic for MismatchedArgCount { | |||
244 | ast::CallExpr::cast(node).unwrap() | 244 | ast::CallExpr::cast(node).unwrap() |
245 | } | 245 | } |
246 | } | 246 | } |
247 | |||
248 | #[cfg(test)] | ||
249 | fn 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 | actual.entry(file_id).or_default().push((range, d.message().to_owned())); | ||
265 | }); | ||
266 | |||
267 | assert_eq!(annotations, actual); | ||
268 | } | ||