mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-23 20:04:21 +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"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"difference",
|
"difference",
|
||||||
"ra_cfg",
|
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"stdx",
|
"stdx",
|
||||||
|
|
|
@ -203,11 +203,15 @@ struct FileMeta {
|
||||||
|
|
||||||
impl From<&Fixture> for ParsedMeta {
|
impl From<&Fixture> for ParsedMeta {
|
||||||
fn from(f: &Fixture) -> Self {
|
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 {
|
Self::File(FileMeta {
|
||||||
path: f.path.to_owned(),
|
path: f.path.to_owned(),
|
||||||
krate: f.crate_name.to_owned(),
|
krate: f.crate_name.to_owned(),
|
||||||
deps: f.deps.to_owned(),
|
deps: f.deps.to_owned(),
|
||||||
cfg: f.cfg.to_owned(),
|
cfg,
|
||||||
edition: f
|
edition: f
|
||||||
.edition
|
.edition
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -38,7 +38,12 @@ impl MockFileData {
|
||||||
|
|
||||||
fn cfg_options(&self) -> CfgOptions {
|
fn cfg_options(&self) -> CfgOptions {
|
||||||
match self {
|
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(),
|
_ => CfgOptions::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@ authors = ["rust-analyzer developers"]
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
# Avoid adding deps here, this crate is widely used in tests it should compile fast!
|
||||||
difference = "2.0.0"
|
difference = "2.0.0"
|
||||||
text-size = "1.0.0"
|
text-size = "1.0.0"
|
||||||
serde_json = "1.0.48"
|
serde_json = "1.0.48"
|
||||||
rustc-hash = "1.1.0"
|
rustc-hash = "1.1.0"
|
||||||
|
|
||||||
ra_cfg = { path = "../ra_cfg" }
|
|
||||||
stdx = { path = "../stdx" }
|
stdx = { path = "../stdx" }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use ra_cfg::CfgOptions;
|
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use stdx::split1;
|
use stdx::split1;
|
||||||
|
|
||||||
|
@ -8,7 +7,8 @@ pub struct Fixture {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
pub crate_name: Option<String>,
|
pub crate_name: Option<String>,
|
||||||
pub deps: Vec<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 edition: Option<String>,
|
||||||
pub env: FxHashMap<String, String>,
|
pub env: FxHashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,8 @@ The offending line: {:?}"#,
|
||||||
let mut krate = None;
|
let mut krate = None;
|
||||||
let mut deps = Vec::new();
|
let mut deps = Vec::new();
|
||||||
let mut edition = None;
|
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();
|
let mut env = FxHashMap::default();
|
||||||
for component in components[1..].iter() {
|
for component in components[1..].iter() {
|
||||||
let (key, value) = split1(component, ':').unwrap();
|
let (key, value) = split1(component, ':').unwrap();
|
||||||
|
@ -82,10 +83,10 @@ The offending line: {:?}"#,
|
||||||
"deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
|
"deps" => deps = value.split(',').map(|it| it.to_string()).collect(),
|
||||||
"edition" => edition = Some(value.to_string()),
|
"edition" => edition = Some(value.to_string()),
|
||||||
"cfg" => {
|
"cfg" => {
|
||||||
for key in value.split(',') {
|
for entry in value.split(',') {
|
||||||
match split1(key, '=') {
|
match split1(entry, '=') {
|
||||||
None => cfg.insert_atom(key.into()),
|
Some((k, v)) => cfg_key_values.push((k.to_string(), v.to_string())),
|
||||||
Some((k, v)) => cfg.insert_key_value(k.into(), v.into()),
|
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]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn parse_fixture_checks_further_indented_metadata() {
|
fn parse_fixture_checks_further_indented_metadata() {
|
||||||
parse_fixture(
|
Fixture::parse(
|
||||||
r"
|
r"
|
||||||
//- /lib.rs
|
//- /lib.rs
|
||||||
mod bar;
|
mod bar;
|
||||||
|
|
|
@ -19,7 +19,6 @@ use serde_json::Value;
|
||||||
use text_size::{TextRange, TextSize};
|
use text_size::{TextRange, TextSize};
|
||||||
|
|
||||||
pub use difference::Changeset as __Changeset;
|
pub use difference::Changeset as __Changeset;
|
||||||
pub use ra_cfg::CfgOptions;
|
|
||||||
pub use rustc_hash::FxHashMap;
|
pub use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
pub use crate::fixture::Fixture;
|
pub use crate::fixture::Fixture;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue