diff --git a/crates/base_db/src/lib.rs b/crates/base_db/src/lib.rs index 55ef9fc24d..c72e254f41 100644 --- a/crates/base_db/src/lib.rs +++ b/crates/base_db/src/lib.rs @@ -172,17 +172,22 @@ impl FileLoader for FileLoaderDelegate<&'_ T> { Some(("mod", Some("rs"))) | Some(("lib", Some("rs"))) => { module_files.list_files_with_extensions(module_file, None) } + // TODO kb for `src/bin/foo.rs`, we need to check for modules in `src/bin/` Some((directory_with_module_name, Some("rs"))) => module_files .list_files_with_extensions( module_file, Some(&format!("../{}/", directory_with_module_name)), ), + // TODO kb also consider the case when there's no `../module_name.rs`, but `../module_name/mod.rs` _ => Vec::new(), }; possible_submodule_files .into_iter() .filter(|(_, extension)| extension == &Some("rs")) + .filter(|(file_name, _)| file_name != &"mod") + .filter(|(file_name, _)| file_name != &"lib") + .filter(|(file_name, _)| file_name != &"main") .map(|(file_name, _)| file_name.to_owned()) .collect() } diff --git a/crates/ide/src/completion/completion_context.rs b/crates/ide/src/completion/completion_context.rs index b4c6eeb35c..74cd16e0a1 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> { .to_module_def(position.file_id) .and_then(|current_module| { let definition_source = current_module.definition_source(db); - if !matches!(definition_source.value, ModuleSource::SourceFile(_)) { - return None; - } let module_definition_source_file = definition_source.file_id.original_file(db); let mod_declaration_candidates = db.possible_sudmobule_names(module_definition_source_file);