From 5766ceab0629acc4464dcc57d00d9cc5c12f1c6b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 15 Nov 2019 13:16:16 +0300 Subject: Add convenience method for testing --- crates/ra_hir_def/src/nameres/collector.rs | 2 +- crates/ra_hir_def/src/nameres/tests/incremental.rs | 6 +++--- crates/ra_hir_def/src/nameres/tests/mod_resolution.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 37d0f3093..83eef821f 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs @@ -798,7 +798,7 @@ mod tests { fn do_limited_resolve(code: &str, limit: u32, poison_limit: u32) -> CrateDefMap { let (db, _file_id) = TestDB::with_single_file(&code); - let krate = db.crate_graph().iter().next().unwrap(); + let krate = db.test_crate(); let def_map = { let edition = db.crate_graph().edition(krate); diff --git a/crates/ra_hir_def/src/nameres/tests/incremental.rs b/crates/ra_hir_def/src/nameres/tests/incremental.rs index 80dcec62f..903a22771 100644 --- a/crates/ra_hir_def/src/nameres/tests/incremental.rs +++ b/crates/ra_hir_def/src/nameres/tests/incremental.rs @@ -1,12 +1,12 @@ use std::sync::Arc; -use ra_db::{SourceDatabase, SourceDatabaseExt}; +use ra_db::SourceDatabaseExt; use super::*; fn check_def_map_is_not_recomputed(initial: &str, file_change: &str) { let (mut db, pos) = TestDB::with_position(initial); - let krate = db.crate_graph().iter().next().unwrap(); + let krate = db.test_crate(); { let events = db.log_executed(|| { db.crate_def_map(krate); @@ -111,7 +111,7 @@ fn typing_inside_a_macro_should_not_invalidate_def_map() { m!(X); ", ); - let krate = db.crate_graph().iter().next().unwrap(); + let krate = db.test_crate(); { let events = db.log_executed(|| { let crate_def_map = db.crate_def_map(krate); diff --git a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs index dee364a14..eb7b85c07 100644 --- a/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs +++ b/crates/ra_hir_def/src/nameres/tests/mod_resolution.rs @@ -656,7 +656,7 @@ fn unresolved_module_diagnostics() { //- /foo.rs ", ); - let krate = db.crate_graph().iter().next().unwrap(); + let krate = db.test_crate(); let crate_def_map = db.crate_def_map(krate); -- cgit v1.2.3