diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-06-09 12:22:38 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-06-09 12:22:38 +0100 |
commit | d4d384e4c8355243d0f22c050e28f79d2593c618 (patch) | |
tree | 981072657529bd6741de51374455d5fc11998d12 /crates/ra_db | |
parent | eb53f5a9e5f798e13681b8fb49d47299fe7011f0 (diff) | |
parent | d8571e076c0bbb3219fb3ed250279b158d75e683 (diff) |
Merge #4813
4813: Simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_db')
-rw-r--r-- | crates/ra_db/src/input.rs | 12 | ||||
-rw-r--r-- | crates/ra_db/src/lib.rs | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 4d2d3b48a..a8d6466ea 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -337,15 +337,11 @@ impl Env { | |||
337 | } | 337 | } |
338 | 338 | ||
339 | impl ExternSource { | 339 | impl ExternSource { |
340 | pub fn extern_path(&self, path: impl AsRef<Path>) -> Option<(ExternSourceId, RelativePathBuf)> { | 340 | pub fn extern_path(&self, path: &Path) -> Option<(ExternSourceId, RelativePathBuf)> { |
341 | let path = path.as_ref(); | ||
342 | self.extern_paths.iter().find_map(|(root_path, id)| { | 341 | self.extern_paths.iter().find_map(|(root_path, id)| { |
343 | if let Ok(rel_path) = path.strip_prefix(root_path) { | 342 | let rel_path = path.strip_prefix(root_path).ok()?; |
344 | let rel_path = RelativePathBuf::from_path(rel_path).ok()?; | 343 | let rel_path = RelativePathBuf::from_path(rel_path).ok()?; |
345 | Some((*id, rel_path)) | 344 | Some((*id, rel_path)) |
346 | } else { | ||
347 | None | ||
348 | } | ||
349 | }) | 345 | }) |
350 | } | 346 | } |
351 | 347 | ||
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index 91e0ee619..2ab314884 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -158,7 +158,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { | |||
158 | if std::path::Path::new(path).is_absolute() { | 158 | if std::path::Path::new(path).is_absolute() { |
159 | let krate = *self.relevant_crates(anchor).get(0)?; | 159 | let krate = *self.relevant_crates(anchor).get(0)?; |
160 | let (extern_source_id, relative_file) = | 160 | let (extern_source_id, relative_file) = |
161 | self.0.crate_graph()[krate].extern_source.extern_path(path)?; | 161 | self.0.crate_graph()[krate].extern_source.extern_path(path.as_ref())?; |
162 | 162 | ||
163 | let source_root = self.0.source_root(SourceRootId(extern_source_id.0)); | 163 | let source_root = self.0.source_root(SourceRootId(extern_source_id.0)); |
164 | source_root.file_by_relative_path(&relative_file) | 164 | source_root.file_by_relative_path(&relative_file) |