mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Add some more cov_mark
s
This commit is contained in:
parent
8c9359b072
commit
b3ac58dfb8
@ -231,7 +231,9 @@ pub(crate) fn complete_expr_path(
|
|||||||
cov_mark::hit!(functional_update);
|
cov_mark::hit!(functional_update);
|
||||||
let missing_fields =
|
let missing_fields =
|
||||||
ctx.sema.record_literal_missing_fields(record_expr);
|
ctx.sema.record_literal_missing_fields(record_expr);
|
||||||
add_default_update(acc, ctx, ty, &missing_fields);
|
if !missing_fields.is_empty() {
|
||||||
|
add_default_update(acc, ctx, ty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,11 @@ pub(crate) fn complete_record_expr_fields(
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let missing_fields = ctx.sema.record_literal_missing_fields(record_expr);
|
let missing_fields = ctx.sema.record_literal_missing_fields(record_expr);
|
||||||
add_default_update(acc, ctx, ty, &missing_fields);
|
|
||||||
|
if !missing_fields.is_empty() {
|
||||||
|
cov_mark::hit!(functional_update_field);
|
||||||
|
add_default_update(acc, ctx, ty);
|
||||||
|
}
|
||||||
if dot_prefix {
|
if dot_prefix {
|
||||||
cov_mark::hit!(functional_update_one_dot);
|
cov_mark::hit!(functional_update_one_dot);
|
||||||
let mut item =
|
let mut item =
|
||||||
@ -78,14 +82,14 @@ pub(crate) fn add_default_update(
|
|||||||
acc: &mut Completions,
|
acc: &mut Completions,
|
||||||
ctx: &CompletionContext<'_>,
|
ctx: &CompletionContext<'_>,
|
||||||
ty: Option<hir::TypeInfo>,
|
ty: Option<hir::TypeInfo>,
|
||||||
missing_fields: &[(hir::Field, hir::Type)],
|
|
||||||
) {
|
) {
|
||||||
let default_trait = ctx.famous_defs().core_default_Default();
|
let default_trait = ctx.famous_defs().core_default_Default();
|
||||||
let impl_default_trait = default_trait
|
let impls_default_trait = default_trait
|
||||||
.zip(ty.as_ref())
|
.zip(ty.as_ref())
|
||||||
.map_or(false, |(default_trait, ty)| ty.original.impls_trait(ctx.db, default_trait, &[]));
|
.map_or(false, |(default_trait, ty)| ty.original.impls_trait(ctx.db, default_trait, &[]));
|
||||||
if impl_default_trait && !missing_fields.is_empty() {
|
if impls_default_trait {
|
||||||
// FIXME: This should make use of scope_def like completions so we get all the other goodies
|
// FIXME: This should make use of scope_def like completions so we get all the other goodies
|
||||||
|
// that is we should handle this like actually completing the default function
|
||||||
let completion_text = "..Default::default()";
|
let completion_text = "..Default::default()";
|
||||||
let mut item = CompletionItem::new(SymbolKind::Field, ctx.source_range(), completion_text);
|
let mut item = CompletionItem::new(SymbolKind::Field, ctx.source_range(), completion_text);
|
||||||
let completion_text =
|
let completion_text =
|
||||||
|
@ -156,6 +156,7 @@ fn main() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn functional_update_no_dot() {
|
fn functional_update_no_dot() {
|
||||||
|
cov_mark::check!(functional_update_field);
|
||||||
// FIXME: This should filter out all completions that do not have the type `Foo`
|
// FIXME: This should filter out all completions that do not have the type `Foo`
|
||||||
check(
|
check(
|
||||||
r#"
|
r#"
|
||||||
|
Loading…
Reference in New Issue
Block a user