diff options
-rw-r--r-- | crates/base_db/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ide/src/completion/completion_context.rs | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 55ef9fc24..c72e254f4 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs | |||
@@ -172,17 +172,22 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> { | |||
172 | Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => { | 172 | Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => { |
173 | module_files.list_files_with_extensions(module_file, None) | 173 | module_files.list_files_with_extensions(module_file, None) |
174 | } | 174 | } |
175 | // TODO kb for `src/bin/foo.rs`, we need to check for modules in `src/bin/` | ||
175 | Some((directory_with_module_name, Some("rs"))) => module_files | 176 | Some((directory_with_module_name, Some("rs"))) => module_files |
176 | .list_files_with_extensions( | 177 | .list_files_with_extensions( |
177 | module_file, | 178 | module_file, |
178 | Some(&format!("../{}/", directory_with_module_name)), | 179 | Some(&format!("../{}/", directory_with_module_name)), |
179 | ), | 180 | ), |
181 | // TODO kb also consider the case when there's no `../module_name.rs`, but `../module_name/mod.rs` | ||
180 | _ => Vec::new(), | 182 | _ => Vec::new(), |
181 | }; | 183 | }; |
182 | 184 | ||
183 | possible_submodule_files | 185 | possible_submodule_files |
184 | .into_iter() | 186 | .into_iter() |
185 | .filter(|(_, extension)| extension == &Some("rs")) | 187 | .filter(|(_, extension)| extension == &Some("rs")) |
188 | .filter(|(file_name, _)| file_name != &"mod") | ||
189 | .filter(|(file_name, _)| file_name != &"lib") | ||
190 | .filter(|(file_name, _)| file_name != &"main") | ||
186 | .map(|(file_name, _)| file_name.to_owned()) | 191 | .map(|(file_name, _)| file_name.to_owned()) |
187 | .collect() | 192 | .collect() |
188 | } | 193 | } |
diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index b4c6eeb35..74cd16e0a 100644 --- a/crates/ide/src/completion/completion_context.rs +++ b/crates/ide/src/completion/completion_context.rs | |||
@@ -117,9 +117,6 @@ impl<'a> CompletionContext<'a> { | |||
117 | .to_module_def(position.file_id) | 117 | .to_module_def(position.file_id) |
118 | .and_then(|current_module| { | 118 | .and_then(|current_module| { |
119 | let definition_source = current_module.definition_source(db); | 119 | let definition_source = current_module.definition_source(db); |
120 | if !matches!(definition_source.value, ModuleSource::SourceFile(_)) { | ||
121 | return None; | ||
122 | } | ||
123 | let module_definition_source_file = definition_source.file_id.original_file(db); | 120 | let module_definition_source_file = definition_source.file_id.original_file(db); |
124 | let mod_declaration_candidates = | 121 | let mod_declaration_candidates = |
125 | db.possible_sudmobule_names(module_definition_source_file); | 122 | db.possible_sudmobule_names(module_definition_source_file); |