aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-05-16 20:49:01 +0100
committerGitHub <[email protected]>2020-05-16 20:49:01 +0100
commitebaa05a4478096aaf3bc2a48d0d171a287422c7c (patch)
tree3a28337d2213a819b241d9d950ca64f6dcaf2345 /crates/ra_ide
parent9322790066fe86056965332078bed74ff7f77293 (diff)
parentbb78d314e15999a68f5eb865486824966c13402f (diff)
Merge #4472
4472: Fix path resolution for module and function with same name r=hasali19 a=hasali19 This fixes #3970 and also fixes completion for the same issue. Co-authored-by: Hasan Ali <[email protected]>
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/completion/complete_qualified_path.rs30
-rw-r--r--crates/ra_ide/src/hover.rs17
2 files changed, 46 insertions, 1 deletions
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
20 let scope = ctx.scope(); 20 let scope = ctx.scope();
21 let context_module = scope.module(); 21 let context_module = scope.module();
22 22
23 let res = match scope.resolve_hir_path(&path) { 23 let res = match scope.resolve_hir_path_qualifier(&path) {
24 Some(res) => res, 24 Some(res) => res,
25 None => return, 25 None => return,
26 }; 26 };
@@ -226,6 +226,34 @@ mod tests {
226 } 226 }
227 227
228 #[test] 228 #[test]
229 fn completes_mod_with_same_name_as_function() {
230 assert_debug_snapshot!(
231 do_reference_completion(
232 r"
233 use self::my::<|>;
234
235 mod my {
236 pub struct Bar;
237 }
238
239 fn my() {}
240 "
241 ),
242 @r###"
243 [
244 CompletionItem {
245 label: "Bar",
246 source_range: 31..31,
247 delete: 31..31,
248 insert: "Bar",
249 kind: Struct,
250 },
251 ]
252 "###
253 );
254 }
255
256 #[test]
229 fn path_visibility() { 257 fn path_visibility() {
230 assert_debug_snapshot!( 258 assert_debug_snapshot!(
231 do_reference_completion( 259 do_reference_completion(
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs
index 06d4f1c63..befa977c7 100644
--- a/crates/ra_ide/src/hover.rs
+++ b/crates/ra_ide/src/hover.rs
@@ -921,4 +921,21 @@ fn func(foo: i32) { if true { <|>foo; }; }
921 &["unsafe trait foo"], 921 &["unsafe trait foo"],
922 ); 922 );
923 } 923 }
924
925 #[test]
926 fn test_hover_mod_with_same_name_as_function() {
927 check_hover_result(
928 "
929 //- /lib.rs
930 use self::m<|>y::Bar;
931
932 mod my {
933 pub struct Bar;
934 }
935
936 fn my() {}
937 ",
938 &["mod my"],
939 );
940 }
924} 941}