diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-27 09:40:57 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-27 09:40:57 +0000 |
commit | 7dfbe28211910d5d7c74a593bf0007c5db3e3496 (patch) | |
tree | 85231799bdc84bcd43ceceee08fe7714a9f21faa /crates | |
parent | 5a3d2332f8d5e382fc06210c260ff6db857ac716 (diff) | |
parent | 8464c45086ee0f5e40a4c9e5e4a76cdfeb3a1ad2 (diff) |
Merge #2087
2087: remove relative_path_buf workaround r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_db/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/mod_resolution.rs | 13 |
2 files changed, 4 insertions, 14 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs index fc5d6d396..0d1ab4843 100644 --- a/crates/ra_db/src/lib.rs +++ b/crates/ra_db/src/lib.rs | |||
@@ -134,10 +134,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { | |||
134 | ) -> Option<FileId> { | 134 | ) -> Option<FileId> { |
135 | let path = { | 135 | let path = { |
136 | let mut path = self.0.file_relative_path(anchor); | 136 | let mut path = self.0.file_relative_path(anchor); |
137 | // Workaround for relative path API: turn `lib.rs` into ``. | 137 | assert!(path.pop()); |
138 | if !path.pop() { | ||
139 | path = RelativePathBuf::default(); | ||
140 | } | ||
141 | path.push(relative_path); | 138 | path.push(relative_path); |
142 | path.normalize() | 139 | path.normalize() |
143 | }; | 140 | }; |
diff --git a/crates/ra_hir/src/nameres/mod_resolution.rs b/crates/ra_hir/src/nameres/mod_resolution.rs index e8b808514..334cdd692 100644 --- a/crates/ra_hir/src/nameres/mod_resolution.rs +++ b/crates/ra_hir/src/nameres/mod_resolution.rs | |||
@@ -30,10 +30,7 @@ impl ModDir { | |||
30 | None => path.push(&name.to_string()), | 30 | None => path.push(&name.to_string()), |
31 | Some(attr_path) => { | 31 | Some(attr_path) => { |
32 | if self.root_non_dir_owner { | 32 | if self.root_non_dir_owner { |
33 | // Workaround for relative path API: turn `lib.rs` into ``. | 33 | assert!(path.pop()); |
34 | if !path.pop() { | ||
35 | path = RelativePathBuf::default(); | ||
36 | } | ||
37 | } | 34 | } |
38 | path.push(attr_path); | 35 | path.push(attr_path); |
39 | } | 36 | } |
@@ -48,17 +45,13 @@ impl ModDir { | |||
48 | name: &Name, | 45 | name: &Name, |
49 | attr_path: Option<&SmolStr>, | 46 | attr_path: Option<&SmolStr>, |
50 | ) -> Result<(FileId, ModDir), RelativePathBuf> { | 47 | ) -> Result<(FileId, ModDir), RelativePathBuf> { |
51 | let empty_path = RelativePathBuf::default(); | ||
52 | let file_id = file_id.original_file(db); | 48 | let file_id = file_id.original_file(db); |
53 | 49 | ||
54 | let mut candidate_files = Vec::new(); | 50 | let mut candidate_files = Vec::new(); |
55 | match attr_to_path(attr_path) { | 51 | match attr_to_path(attr_path) { |
56 | Some(attr_path) => { | 52 | Some(attr_path) => { |
57 | let base = if self.root_non_dir_owner { | 53 | let base = |
58 | self.path.parent().unwrap_or(&empty_path) | 54 | if self.root_non_dir_owner { self.path.parent().unwrap() } else { &self.path }; |
59 | } else { | ||
60 | &self.path | ||
61 | }; | ||
62 | candidate_files.push(base.join(attr_path)) | 55 | candidate_files.push(base.join(attr_path)) |
63 | } | 56 | } |
64 | None => { | 57 | None => { |