diff --git a/crates/ide_completion/src/completions/record.rs b/crates/ide_completion/src/completions/record.rs index 54fc748d1c4..80132c2566a 100644 --- a/crates/ide_completion/src/completions/record.rs +++ b/crates/ide_completion/src/completions/record.rs @@ -20,7 +20,7 @@ pub(crate) fn complete_record(acc: &mut Completions, ctx: &CompletionContext) -> }); let missing_fields = ctx.sema.record_literal_missing_fields(record_expr); - if impl_default_trait && !missing_fields.is_empty() { + if impl_default_trait && !missing_fields.is_empty() && ctx.path_qual().is_none() { let completion_text = "..Default::default()"; let mut item = CompletionItem::new( CompletionKind::Snippet, diff --git a/crates/ide_completion/src/tests/record.rs b/crates/ide_completion/src/tests/record.rs index 3769977b628..30b1f2c1c97 100644 --- a/crates/ide_completion/src/tests/record.rs +++ b/crates/ide_completion/src/tests/record.rs @@ -182,4 +182,24 @@ fn main() { sn Foo {…} Foo { foo1: ${1:()}, foo2: ${2:()} }$0 "#]], ); + check( + r#" +//- minicore:default +struct Foo { foo1: u32, foo2: u32 } +impl Default for Foo { + fn default() -> Self { loop {} } +} + +fn main() { + let thing = 1; + let foo = Foo { foo1: 0, foo2: 0 }; + let foo2 = Foo { thing, ..Default::$0 } +} +"#, + expect![[r#" + fn default() (as Default) fn() -> Self + fd foo1 u32 + fd foo2 u32 + "#]], + ); }