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>
This commit is contained in:
bors[bot] 2022-02-21 12:52:11 +00:00 committed by GitHub
commit 8c718a47c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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(())