about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-21 12:52:11 +0000
committerGitHub <noreply@github.com>2022-02-21 12:52:11 +0000
commit8c718a47c1229e959d46887806f57c5314e9785b (patch)
tree360f7ecb026e3dbd893ede9be8a790c7070cecf8
parent36f302355b864d9c4a454e1436aad4ce0b91f70a (diff)
parent50458e350f355a6f89877fea925dea3e2fa4ef2f (diff)
downloadrust-8c718a47c1229e959d46887806f57c5314e9785b.tar.gz
rust-8c718a47c1229e959d46887806f57c5314e9785b.zip
Merge #11517
11517: fix: Fix qualfiied record literal completion triggering too eagerly r=Veykril a=Veykril

Supercedes https://github.com/rust-analyzer/rust-analyzer/pull/10909
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10889
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
-rw-r--r--crates/ide_completion/src/completions/record.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/ide_completion/src/completions/record.rs b/crates/ide_completion/src/completions/record.rs
index 13b47356197..78d06231060 100644
--- a/crates/ide_completion/src/completions/record.rs
+++ b/crates/ide_completion/src/completions/record.rs
@@ -63,11 +63,12 @@ pub(crate) fn complete_record_literal(
     }
 
     if let hir::Adt::Struct(strukt) = ctx.expected_type.as_ref()?.as_adt()? {
-        let module = if let Some(module) = ctx.module { module } else { strukt.module(ctx.db) };
+        if ctx.path_qual().is_none() {
+            let module = if let Some(module) = ctx.module { module } else { strukt.module(ctx.db) };
+            let path = module.find_use_path(ctx.db, hir::ModuleDef::from(strukt));
 
-        let path = module.find_use_path(ctx.db, hir::ModuleDef::from(strukt));
-
-        acc.add_struct_literal(ctx, strukt, path, None);
+            acc.add_struct_literal(ctx, strukt, path, None);
+        }
     }
 
     Some(())