From 2c00bd8c6a9476dbac427c84941fe6f54a8a95b1 Mon Sep 17 00:00:00 2001 From: vsrs Date: Sat, 16 May 2020 15:23:43 +0300 Subject: Propogate fixture meta to AnalysisHost Except crate name. --- crates/ra_db/src/fixture.rs | 10 ++-------- crates/ra_db/src/input.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'crates/ra_db/src') diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs index 8b62fe9aa..fd535ab15 100644 --- a/crates/ra_db/src/fixture.rs +++ b/crates/ra_db/src/fixture.rs @@ -254,20 +254,14 @@ impl From<&FixtureMeta> for ParsedMeta { } FixtureMeta::File(f) => Self::File(FileMeta { path: f.path.to_owned().into(), - krate: f.krate.to_owned().into(), + krate: f.crate_name.to_owned().into(), deps: f.deps.to_owned(), cfg: f.cfg.to_owned(), edition: f .edition .as_ref() .map_or(Edition::Edition2018, |v| Edition::from_str(&v).unwrap()), - env: { - let mut env = Env::default(); - for (k, v) in &f.env { - env.set(&k, v.to_owned()); - } - env - }, + env: Env::from(f.env.iter()), }), } } diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index ab14e2d5e..4d2d3b48a 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs @@ -311,6 +311,21 @@ impl fmt::Display for Edition { } } +impl<'a, T> From for Env +where + T: Iterator, +{ + fn from(iter: T) -> Self { + let mut result = Self::default(); + + for (k, v) in iter { + result.entries.insert(k.to_owned(), v.to_owned()); + } + + result + } +} + impl Env { pub fn set(&mut self, env: &str, value: String) { self.entries.insert(env.to_owned(), value); -- cgit v1.2.3