fix: Do not show functional update completion when already qualified

This commit is contained in:
Lukas Wirth 2021-08-21 20:45:15 +02:00
parent 9e3517f8f3
commit 833de22d0b
2 changed files with 21 additions and 1 deletions

View File

@ -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,

View File

@ -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
"#]],
);
}