From 6996ec860bde7e6186ba8609b68ef51b8713e2ea Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Jun 2020 18:17:43 +0200 Subject: [PATCH] Drop rarely used fixture functionality --- crates/ra_db/src/fixture.rs | 18 ++---------------- crates/ra_hir_def/src/nameres/tests.rs | 25 ------------------------- crates/test_utils/src/fixture.rs | 12 ------------ 3 files changed, 2 insertions(+), 53 deletions(-) diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs index f7d9118a9a..bf897baffc 100644 --- a/crates/ra_db/src/fixture.rs +++ b/crates/ra_db/src/fixture.rs @@ -114,7 +114,6 @@ fn with_single_file(db: &mut dyn SourceDatabaseExt, ra_fixture: &str) -> FileId let crate_graph = if let Some(entry) = fixture { let meta = match ParsedMeta::from(&entry.meta) { ParsedMeta::File(it) => it, - _ => panic!("with_single_file only support file meta"), }; let mut crate_graph = CrateGraph::default(); @@ -159,21 +158,14 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option = None; let mut file_set = FileSet::default(); - let mut source_root_id = WORKSPACE; - let mut source_root_prefix = "/".to_string(); + let source_root_id = WORKSPACE; + let source_root_prefix = "/".to_string(); let mut file_id = FileId(0); let mut file_position = None; for entry in fixture.iter() { let meta = match ParsedMeta::from(&entry.meta) { - ParsedMeta::Root { path } => { - let file_set = std::mem::replace(&mut file_set, FileSet::default()); - db.set_source_root(source_root_id, Arc::new(SourceRoot::new_local(file_set))); - source_root_id.0 += 1; - source_root_prefix = path; - continue; - } ParsedMeta::File(it) => it, }; assert!(meta.path.starts_with(&source_root_prefix)); @@ -239,7 +231,6 @@ fn with_files(db: &mut dyn SourceDatabaseExt, fixture: &str) -> Option for ParsedMeta { fn from(meta: &FixtureMeta) -> Self { match meta { - FixtureMeta::Root { path } => { - // `Self::Root` causes a false warning: 'variant is never constructed: `Root` ' - // see https://github.com/rust-lang/rust/issues/69018 - ParsedMeta::Root { path: path.to_owned() } - } FixtureMeta::File(f) => Self::File(FileMeta { path: f.path.to_owned(), krate: f.crate_name.to_owned(), diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index 05cd0297d1..503099fb74 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs @@ -423,31 +423,6 @@ fn extern_crate_rename_2015_edition() { ); } -#[test] -fn import_across_source_roots() { - let map = def_map( - " - //- /main.rs crate:main deps:test_crate - use test_crate::a::b::C; - - //- root /test_crate/ - - //- /test_crate/lib.rs crate:test_crate - pub mod a { - pub mod b { - pub struct C; - } - } - - ", - ); - - assert_snapshot!(map, @r###" - ⋮crate - ⋮C: t v - "###); -} - #[test] fn reexport_across_crates() { let map = def_map( diff --git a/crates/test_utils/src/fixture.rs b/crates/test_utils/src/fixture.rs index d0a7320310..0dbeb01b1b 100644 --- a/crates/test_utils/src/fixture.rs +++ b/crates/test_utils/src/fixture.rs @@ -10,7 +10,6 @@ pub struct FixtureEntry { #[derive(Debug, Eq, PartialEq)] pub enum FixtureMeta { - Root { path: String }, File(FileMeta), } @@ -27,7 +26,6 @@ pub struct FileMeta { impl FixtureMeta { pub fn path(&self) -> &str { match self { - FixtureMeta::Root { path } => &path, FixtureMeta::File(f) => &f.path, } } @@ -35,21 +33,18 @@ impl FixtureMeta { pub fn crate_name(&self) -> Option<&String> { match self { FixtureMeta::File(f) => f.crate_name.as_ref(), - _ => None, } } pub fn cfg_options(&self) -> Option<&CfgOptions> { match self { FixtureMeta::File(f) => Some(&f.cfg), - _ => None, } } pub fn edition(&self) -> Option<&String> { match self { FixtureMeta::File(f) => f.edition.as_ref(), - _ => None, } } @@ -63,7 +58,6 @@ impl FixtureMeta { Self { iter: match meta { FixtureMeta::File(f) => Some(f.env.iter()), - _ => None, }, } } @@ -146,12 +140,6 @@ The offending line: {:?}"#, fn parse_meta(meta: &str) -> FixtureMeta { let components = meta.split_ascii_whitespace().collect::>(); - if components[0] == "root" { - let path = components[1].to_string(); - assert!(path.starts_with("/") && path.ends_with("/")); - return FixtureMeta::Root { path }; - } - let path = components[0].to_string(); assert!(path.starts_with("/"));