diff --git a/crates/ide_diagnostics/src/handlers/missing_fields.rs b/crates/ide_diagnostics/src/handlers/missing_fields.rs index 8d17a7e714..715ac8f974 100644 --- a/crates/ide_diagnostics/src/handlers/missing_fields.rs +++ b/crates/ide_diagnostics/src/handlers/missing_fields.rs @@ -1,6 +1,6 @@ use either::Either; -use hir::{db::AstDatabase, InFile}; -use ide_db::{assists::Assist, source_change::SourceChange}; +use hir::{db::AstDatabase, InFile, Type}; +use ide_db::{assists::Assist, helpers::FamousDefs, source_change::SourceChange}; use rustc_hash::FxHashMap; use stdx::format_to; use syntax::{algo, ast::make, AstNode, SyntaxNodePtr}; @@ -63,6 +63,19 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option { + Some(make::ext::expr_default()) + } + _ => Some(make::ext::expr_todo()), + } + }; + for (f, ty) in missing_fields.iter() { let field_expr = if let Some(local_candidate) = locals.get(&f.name(ctx.sema.db)) { cov_mark::hit!(field_shorthand); @@ -70,10 +83,10 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &hir::MissingFields) -> Option ast::Expr { expr_from_text("todo!()") } + pub fn expr_default() -> ast::Expr { + expr_from_text("Default::default()") + } pub fn empty_block_expr() -> ast::BlockExpr { block_expr(None, None) }