diff --git a/crates/ide-assists/src/handlers/destructure_struct_binding.rs b/crates/ide-assists/src/handlers/destructure_struct_binding.rs index 4edc52b614a..c1a3f930265 100644 --- a/crates/ide-assists/src/handlers/destructure_struct_binding.rs +++ b/crates/ide-assists/src/handlers/destructure_struct_binding.rs @@ -107,6 +107,10 @@ fn collect_data(ident_pat: ast::IdentPat, ctx: &AssistContext<'_>) -> Option ast::RecordPatFieldList { let mut fields = fields.into_iter().join(", "); if let Some(rest_pat) = rest_pat { - format_to!(fields, ", {rest_pat}"); + if !fields.is_empty() { + fields.push_str(", "); + } + format_to!(fields, "{rest_pat}"); } ast_from_text(&format!("fn f(S {{ {fields} }}: ()))")) }