aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-17 14:42:02 +0000
committerGitHub <[email protected]>2020-03-17 14:42:02 +0000
commitec1312ef38092a4c8f49b57185707c95e00129fa (patch)
tree4a8011773870657b0573d2ea587745999bb14d98 /crates/ra_db
parent2720e2374be951bb762ff2815dd67c7ffe3419b7 (diff)
parent2dd887de4761e2493f4df56233b0e11185d74d63 (diff)
Merge pull request #3582 from kiljacken/out-dir-from-check
Update OUT_DIR based on `cargo check` output
Diffstat (limited to 'crates/ra_db')
-rw-r--r--crates/ra_db/src/input.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index bde843001..e371f849d 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -6,7 +6,11 @@
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}; 9use std::{
10 fmt, ops,
11 path::{Path, PathBuf},
12 str::FromStr,
13};
10 14
11use ra_cfg::CfgOptions; 15use ra_cfg::CfgOptions;
12use ra_syntax::SmolStr; 16use ra_syntax::SmolStr;
@@ -144,7 +148,7 @@ pub struct Env {
144// crate. We store a map to allow remap it to ExternSourceId 148// crate. We store a map to allow remap it to ExternSourceId
145#[derive(Default, Debug, Clone, PartialEq, Eq)] 149#[derive(Default, Debug, Clone, PartialEq, Eq)]
146pub struct ExternSource { 150pub struct ExternSource {
147 extern_paths: FxHashMap<String, ExternSourceId>, 151 extern_paths: FxHashMap<PathBuf, ExternSourceId>,
148} 152}
149 153
150#[derive(Debug, Clone, PartialEq, Eq)] 154#[derive(Debug, Clone, PartialEq, Eq)]
@@ -294,13 +298,10 @@ impl Env {
294} 298}
295 299
296impl ExternSource { 300impl ExternSource {
297 pub fn extern_path(&self, path: &str) -> Option<(ExternSourceId, RelativePathBuf)> { 301 pub fn extern_path(&self, path: impl AsRef<Path>) -> Option<(ExternSourceId, RelativePathBuf)> {
302 let path = path.as_ref();
298 self.extern_paths.iter().find_map(|(root_path, id)| { 303 self.extern_paths.iter().find_map(|(root_path, id)| {
299 if path.starts_with(root_path) { 304 if let Ok(rel_path) = path.strip_prefix(root_path) {
300 let mut rel_path = &path[root_path.len()..];
301 if rel_path.starts_with("/") {
302 rel_path = &rel_path[1..];
303 }
304 let rel_path = RelativePathBuf::from_path(rel_path).ok()?; 305 let rel_path = RelativePathBuf::from_path(rel_path).ok()?;
305 Some((id.clone(), rel_path)) 306 Some((id.clone(), rel_path))
306 } else { 307 } else {
@@ -309,8 +310,8 @@ impl ExternSource {
309 }) 310 })
310 } 311 }
311 312
312 pub fn set_extern_path(&mut self, root_path: &str, root: ExternSourceId) { 313 pub fn set_extern_path(&mut self, root_path: &Path, root: ExternSourceId) {
313 self.extern_paths.insert(root_path.to_owned(), root); 314 self.extern_paths.insert(root_path.to_path_buf(), root);
314 } 315 }
315} 316}
316 317