mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Finish transition to cfgs from the separate atoms and features.
This commit is contained in:
parent
733ef3163c
commit
055b9b64bc
2 changed files with 1 additions and 47 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use rustc_hash::FxHashSet;
|
||||
use serde::Deserialize;
|
||||
|
||||
/// Roots and crates that compose this Rust project.
|
||||
|
@ -28,16 +28,9 @@ pub struct Crate {
|
|||
pub(crate) edition: Edition,
|
||||
pub(crate) deps: Vec<Dep>,
|
||||
|
||||
// This is the preferred method of providing cfg options.
|
||||
#[serde(default)]
|
||||
pub(crate) cfg: FxHashSet<String>,
|
||||
|
||||
// These two are here for transition only.
|
||||
#[serde(default)]
|
||||
pub(crate) atom_cfgs: FxHashSet<String>,
|
||||
#[serde(default)]
|
||||
pub(crate) key_value_cfgs: FxHashMap<String, String>,
|
||||
|
||||
pub(crate) out_dir: Option<PathBuf>,
|
||||
pub(crate) proc_macro_dylib_path: Option<PathBuf>,
|
||||
}
|
||||
|
@ -99,37 +92,4 @@ mod tests {
|
|||
assert!(krate.cfg.contains(&"feature=feature_2".to_string()));
|
||||
assert!(krate.cfg.contains(&"other=value".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_crate_deserialization_old_json() {
|
||||
let raw_json = json!( {
|
||||
"crate_id": 2,
|
||||
"root_module": "this/is/a/file/path.rs",
|
||||
"deps": [
|
||||
{
|
||||
"crate": 1,
|
||||
"name": "some_dep_crate"
|
||||
},
|
||||
],
|
||||
"edition": "2015",
|
||||
"atom_cfgs": [
|
||||
"atom_1",
|
||||
"atom_2",
|
||||
],
|
||||
"key_value_cfgs": {
|
||||
"feature": "feature_1",
|
||||
"feature": "feature_2",
|
||||
"other": "value",
|
||||
},
|
||||
});
|
||||
|
||||
let krate: Crate = serde_json::from_value(raw_json).unwrap();
|
||||
|
||||
assert!(krate.atom_cfgs.contains(&"atom_1".to_string()));
|
||||
assert!(krate.atom_cfgs.contains(&"atom_2".to_string()));
|
||||
assert!(krate.key_value_cfgs.contains_key(&"feature".to_string()));
|
||||
assert_eq!(krate.key_value_cfgs.get("feature"), Some(&"feature_2".to_string()));
|
||||
assert!(krate.key_value_cfgs.contains_key(&"other".to_string()));
|
||||
assert_eq!(krate.key_value_cfgs.get("other"), Some(&"value".to_string()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,12 +280,6 @@ impl ProjectWorkspace {
|
|||
}
|
||||
}
|
||||
}
|
||||
for name in &krate.atom_cfgs {
|
||||
opts.insert_atom(name.into());
|
||||
}
|
||||
for (key, value) in &krate.key_value_cfgs {
|
||||
opts.insert_key_value(key.into(), value.into());
|
||||
}
|
||||
opts
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue