Unnamed repository; edit this file 'description' to name the repository.
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 <[email protected]>
bors[bot] 2022-02-21
parent 36f3023 · parent 50458e3 · commit 8c718a4
-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 13b4735619..78d0623106 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(())