mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 05:08:52 +00:00
Cut problematic dependency
This commit is contained in:
parent
fdf86aee18
commit
84cd28fddc
6 changed files with 31 additions and 15 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1664,7 +1664,6 @@ name = "test_utils"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"difference",
|
||||
"ra_cfg",
|
||||
"rustc-hash",
|
||||
"serde_json",
|
||||
"stdx",
|
||||
|
|
|
@ -203,11 +203,15 @@ struct FileMeta {
|
|||
|
||||
impl From<&Fixture> for ParsedMeta {
|
||||
fn from(f: &Fixture) -> Self {
|
||||
let mut cfg = CfgOptions::default();
|
||||
f.cfg_atoms.iter().for_each(|it| cfg.insert_atom(it.into()));
|
||||
f.cfg_key_values.iter().for_each(|(k, v)| cfg.insert_key_value(k.into(), v.into()));
|
||||
|
||||
Self::File(FileMeta {
|
||||
path: f.path.to_owned(),
|
||||
krate: f.crate_name.to_owned(),
|
||||
deps: f.deps.to_owned(),
|
||||
cfg: f.cfg.to_owned(),
|
||||
cfg,
|
||||
edition: f
|
||||
.edition
|
||||
.as_ref()
|
||||
|
|
|
@ -38,7 +38,12 @@ impl MockFileData {
|
|||
|
||||
fn cfg_options(&self) -> CfgOptions {
|
||||
match self {
|
||||
MockFileData::Fixture(f) => f.cfg.clone(),
|
||||
MockFileData::Fixture(f) => {
|
||||
let mut cfg = CfgOptions::default();
|
||||
f.cfg_atoms.iter().for_each(|it| cfg.insert_atom(it.into()));
|
||||
f.cfg_key_values.iter().for_each(|(k, v)| cfg.insert_key_value(k.into(), v.into()));
|
||||
cfg
|
||||
}
|
||||
_ => CfgOptions::default(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,10 +8,9 @@ authors = ["rust-analyzer developers"]
|
|||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
# Avoid adding deps here, this crate is widely used in tests it should compile fast!
|
||||
difference = "2.0.0"
|
||||
text-size = "1.0.0"
|
||||
serde_json = "1.0.48"
|
||||
rustc-hash = "1.1.0"
|
||||
|
||||
ra_cfg = { path = "../ra_cfg" }
|
||||
stdx = { path = "../stdx" }
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use ra_cfg::CfgOptions;
|
||||
use rustc_hash::FxHashMap;
|
||||
use stdx::split1;
|
||||
|
||||
|
@ -8,7 +7,8 @@ pub struct Fixture {
|
|||
pub text: String,
|
||||
pub crate_name: Option<String>,
|
||||
pub deps: Vec<String>,
|
||||
pub cfg: CfgOptions,
|
||||
pub cfg_atoms: Vec<String>,
|
||||
pub cfg_key_values: Vec<(String, String)>,
|
||||
pub edition: Option<String>,
|
||||
pub env: FxHashMap<String, String>,
|
||||
}
|
||||
|
@ -73,7 +73,8 @@ The offending line: {:?}"#,
|
|||
let mut krate = None;
|
||||
let mut deps = Vec::new();
|
||||
let mut edition = None;
|
||||
let mut cfg = CfgOptions::default();
|
||||
let mut cfg_atoms = Vec::new();
|
||||
let mut cfg_key_values = Vec::new();
|
||||
let mut env = FxHashMap::default();
|
||||
for component in components[1..].iter() {
|
||||
let (key, value) = split1(component, ':').unwrap();
|
||||
|
@ -82,10 +83,10 @@ The offending line: {:?}"#,
|
|||
"deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
|
||||
"edition" => edition = Some(value.to_string()),
|
||||
"cfg" => {
|
||||
for key in value.split(',') {
|
||||
match split1(key, '=') {
|
||||
None => cfg.insert_atom(key.into()),
|
||||
Some((k, v)) => cfg.insert_key_value(k.into(), v.into()),
|
||||
for entry in value.split(',') {
|
||||
match split1(entry, '=') {
|
||||
Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
|
||||
None => cfg_atoms.push(entry.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +101,16 @@ The offending line: {:?}"#,
|
|||
}
|
||||
}
|
||||
|
||||
Fixture { path, text: String::new(), crate_name: krate, deps, edition, cfg, env }
|
||||
Fixture {
|
||||
path,
|
||||
text: String::new(),
|
||||
crate_name: krate,
|
||||
deps,
|
||||
cfg_atoms,
|
||||
cfg_key_values,
|
||||
edition,
|
||||
env,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -152,7 +162,7 @@ fn indent_len(s: &str) -> usize {
|
|||
#[test]
|
||||
#[should_panic]
|
||||
fn parse_fixture_checks_further_indented_metadata() {
|
||||
parse_fixture(
|
||||
Fixture::parse(
|
||||
r"
|
||||
//- /lib.rs
|
||||
mod bar;
|
||||
|
|
|
@ -19,7 +19,6 @@ use serde_json::Value;
|
|||
use text_size::{TextRange, TextSize};
|
||||
|
||||
pub use difference::Changeset as __Changeset;
|
||||
pub use ra_cfg::CfgOptions;
|
||||
pub use rustc_hash::FxHashMap;
|
||||
|
||||
pub use crate::fixture::Fixture;
|
||||
|
|
Loading…
Reference in a new issue