From 001a86dc03104b75df732d69257d22526cf422b7 Mon Sep 17 00:00:00 2001 From: Hasan Ali Date: Fri, 15 May 2020 22:23:49 +0100 Subject: Fix completion and hover for module and function of same name --- .../src/completion/complete_qualified_path.rs | 30 +++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide/src/completion') diff --git a/crates/ra_ide/src/completion/complete_qualified_path.rs b/crates/ra_ide/src/completion/complete_qualified_path.rs index 7fcd22525..db7430454 100644 --- a/crates/ra_ide/src/completion/complete_qualified_path.rs +++ b/crates/ra_ide/src/completion/complete_qualified_path.rs @@ -20,7 +20,7 @@ pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionCon let scope = ctx.scope(); let context_module = scope.module(); - let res = match scope.resolve_hir_path(&path) { + let res = match scope.resolve_hir_path_qualifier(&path) { Some(res) => res, None => return, }; @@ -225,6 +225,34 @@ mod tests { ); } + #[test] + fn completes_mod_with_same_name_as_function() { + assert_debug_snapshot!( + do_reference_completion( + r" + use self::my::<|>; + + mod my { + pub struct Bar; + } + + fn my() {} + " + ), + @r###" + [ + CompletionItem { + label: "Bar", + source_range: 31..31, + delete: 31..31, + insert: "Bar", + kind: Struct, + }, + ] + "### + ); + } + #[test] fn path_visibility() { assert_debug_snapshot!( -- cgit v1.2.3