Drop rarely used fixture functionality
This commit is contained in:
parent
f304874c8c
commit
6996ec860b
@ -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<FilePosit
|
||||
let mut default_crate_root: Option<FileId> = 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<FilePosit
|
||||
}
|
||||
|
||||
enum ParsedMeta {
|
||||
Root { path: String },
|
||||
File(FileMeta),
|
||||
}
|
||||
|
||||
@ -255,11 +246,6 @@ struct FileMeta {
|
||||
impl From<&FixtureMeta> 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(),
|
||||
|
@ -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(
|
||||
|
@ -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 @@ pub fn path(&self) -> &str {
|
||||
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 @@ fn new(meta: &'a FixtureMeta) -> Self {
|
||||
Self {
|
||||
iter: match meta {
|
||||
FixtureMeta::File(f) => Some(f.env.iter()),
|
||||
_ => None,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -146,12 +140,6 @@ pub fn parse_fixture(ra_fixture: &str) -> Vec<FixtureEntry> {
|
||||
fn parse_meta(meta: &str) -> FixtureMeta {
|
||||
let components = meta.split_ascii_whitespace().collect::<Vec<_>>();
|
||||
|
||||
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("/"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user