aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_db/src/lib.rs5
-rw-r--r--crates/ra_hir/src/nameres/mod_resolution.rs13
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 => {