diff options
author | Alexander Andreev <[email protected]> | 2019-07-14 07:24:18 +0100 |
---|---|---|
committer | Alexander Andreev <[email protected]> | 2019-07-14 07:24:18 +0100 |
commit | 9c75f30272d8c520089a9937544bb77423b52a5c (patch) | |
tree | 3f000814aa05a6d5c9adec1c7058f57691ff087f /crates/ra_hir/src/nameres/collector.rs | |
parent | 22b863c53401971200ed0d94a6f4d9389891c608 (diff) |
Fixed request comments
Diffstat (limited to 'crates/ra_hir/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index b8840e37c..7f765caf3 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -1,3 +1,5 @@ | |||
1 | use std::borrow::Cow; | ||
2 | |||
1 | use arrayvec::ArrayVec; | 3 | use arrayvec::ArrayVec; |
2 | use ra_db::FileId; | 4 | use ra_db::FileId; |
3 | use ra_syntax::{ast, SmolStr}; | 5 | use ra_syntax::{ast, SmolStr}; |
@@ -650,7 +652,7 @@ fn resolve_submodule( | |||
650 | let mut candidates = ArrayVec::<[_; 3]>::new(); | 652 | let mut candidates = ArrayVec::<[_; 3]>::new(); |
651 | let file_attr_mod = attr_path.map(|file_path| { | 653 | let file_attr_mod = attr_path.map(|file_path| { |
652 | let file_path = normalize_attribute_path(file_path); | 654 | let file_path = normalize_attribute_path(file_path); |
653 | let file_attr_mod = dir_path.join(file_path).normalize(); | 655 | let file_attr_mod = dir_path.join(file_path.as_ref()).normalize(); |
654 | candidates.push(file_attr_mod.clone()); | 656 | candidates.push(file_attr_mod.clone()); |
655 | 657 | ||
656 | file_attr_mod | 658 | file_attr_mod |
@@ -676,14 +678,18 @@ fn resolve_submodule( | |||
676 | } | 678 | } |
677 | } | 679 | } |
678 | 680 | ||
679 | fn normalize_attribute_path(file_path: &SmolStr) -> String { | 681 | fn normalize_attribute_path(file_path: &SmolStr) -> Cow<str> { |
680 | let current_dir = "./"; | 682 | let current_dir = "./"; |
681 | 683 | let windows_path_separator = r#"\"#; | |
682 | let separator = |path: &str| path.replace("\\", "/"); | 684 | let current_dir_normalize = if file_path.starts_with(current_dir) { |
683 | if file_path.starts_with(current_dir) { | 685 | &file_path[current_dir.len()..] |
684 | separator(&file_path[current_dir.len()..]) | 686 | } else { |
687 | file_path.as_str() | ||
688 | }; | ||
689 | if current_dir_normalize.contains(windows_path_separator) { | ||
690 | Cow::Owned(current_dir_normalize.replace(windows_path_separator, "/")) | ||
685 | } else { | 691 | } else { |
686 | separator(file_path.as_str()) | 692 | Cow::Borrowed(current_dir_normalize) |
687 | } | 693 | } |
688 | } | 694 | } |
689 | 695 | ||