aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-07-21 16:17:21 +0100
committerAleksey Kladov <[email protected]>2020-07-21 16:17:21 +0100
commitb68ef1231daf6eb1abeb06a30dc89af1254b833d (patch)
tree6c134b0dc7c2d2cb33d08fd8f73bff594453b4ec /crates
parenteb613c74da3b82529ed269817b388a3a37dff1fc (diff)
More Rustic API for Env
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_db/src/fixture.rs2
-rw-r--r--crates/ra_db/src/input.rs17
-rw-r--r--crates/ra_ide/src/mock_analysis.rs4
-rw-r--r--crates/ra_project_model/src/lib.rs5
4 files changed, 8 insertions, 20 deletions
diff --git a/crates/ra_db/src/fixture.rs b/crates/ra_db/src/fixture.rs
index 209713987..2aafb9965 100644
--- a/crates/ra_db/src/fixture.rs
+++ b/crates/ra_db/src/fixture.rs
@@ -222,7 +222,7 @@ impl From<Fixture> for FileMeta {
222 .edition 222 .edition
223 .as_ref() 223 .as_ref()
224 .map_or(Edition::Edition2018, |v| Edition::from_str(&v).unwrap()), 224 .map_or(Edition::Edition2018, |v| Edition::from_str(&v).unwrap()),
225 env: Env::from(f.env.iter()), 225 env: f.env.into_iter().collect(),
226 } 226 }
227 } 227 }
228} 228}
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index aaa492759..6f2e5cfc7 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -6,7 +6,7 @@
6//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how 6//! actual IO. See `vfs` and `project_model` in the `rust-analyzer` crate for how
7//! actual IO is done and lowered to input. 7//! actual IO is done and lowered to input.
8 8
9use std::{fmt, ops, str::FromStr, sync::Arc}; 9use std::{fmt, iter::FromIterator, ops, str::FromStr, sync::Arc};
10 10
11use ra_cfg::CfgOptions; 11use ra_cfg::CfgOptions;
12use ra_syntax::SmolStr; 12use ra_syntax::SmolStr;
@@ -298,18 +298,9 @@ impl fmt::Display for Edition {
298 } 298 }
299} 299}
300 300
301impl<'a, T> From<T> for Env 301impl FromIterator<(String, String)> for Env {
302where 302 fn from_iter<T: IntoIterator<Item = (String, String)>>(iter: T) -> Self {
303 T: Iterator<Item = (&'a String, &'a String)>, 303 Env { entries: FromIterator::from_iter(iter) }
304{
305 fn from(iter: T) -> Self {
306 let mut result = Self::default();
307
308 for (k, v) in iter {
309 result.entries.insert(k.to_owned(), v.to_owned());
310 }
311
312 result
313 } 304 }
314} 305}
315 306
diff --git a/crates/ra_ide/src/mock_analysis.rs b/crates/ra_ide/src/mock_analysis.rs
index b28054688..c7e0f4b58 100644
--- a/crates/ra_ide/src/mock_analysis.rs
+++ b/crates/ra_ide/src/mock_analysis.rs
@@ -2,7 +2,7 @@
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use ra_cfg::CfgOptions; 4use ra_cfg::CfgOptions;
5use ra_db::{CrateName, Env, FileSet, SourceRoot, VfsPath}; 5use ra_db::{CrateName, FileSet, SourceRoot, VfsPath};
6use test_utils::{ 6use test_utils::{
7 extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER, 7 extract_annotations, extract_range_or_offset, Fixture, RangeOrOffset, CURSOR_MARKER,
8}; 8};
@@ -110,7 +110,7 @@ impl MockAnalysis {
110 data.edition.and_then(|it| it.parse().ok()).unwrap_or(Edition::Edition2018); 110 data.edition.and_then(|it| it.parse().ok()).unwrap_or(Edition::Edition2018);
111 111
112 let file_id = FileId(i as u32 + 1); 112 let file_id = FileId(i as u32 + 1);
113 let env = Env::from(data.env.iter()); 113 let env = data.env.into_iter().collect();
114 if path == "/lib.rs" || path == "/main.rs" { 114 if path == "/lib.rs" || path == "/main.rs" {
115 root_crate = Some(crate_graph.add_crate_root( 115 root_crate = Some(crate_graph.add_crate_root(
116 file_id, 116 file_id,
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 2bb156610..6da4d7928 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -258,10 +258,7 @@ impl ProjectWorkspace {
258 let file_path = &krate.root_module; 258 let file_path = &krate.root_module;
259 let file_id = load(&file_path)?; 259 let file_id = load(&file_path)?;
260 260
261 let mut env = Env::default(); 261 let env = krate.env.clone().into_iter().collect();
262 for (k, v) in &krate.env {
263 env.set(k, v.clone());
264 }
265 let proc_macro = krate 262 let proc_macro = krate
266 .proc_macro_dylib_path 263 .proc_macro_dylib_path
267 .clone() 264 .clone()