From f51b1615685f6e5e46c72df96e265facdf00d333 Mon Sep 17 00:00:00 2001 From: Wyatt Herkamp Date: Thu, 20 Jun 2024 08:54:23 -0400 Subject: [PATCH] Check that Expr is none before adding fixup --- crates/hir-expand/src/fixup.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/hir-expand/src/fixup.rs b/crates/hir-expand/src/fixup.rs index eadb2e19d1..9fdf4aa4f7 100644 --- a/crates/hir-expand/src/fixup.rs +++ b/crates/hir-expand/src/fixup.rs @@ -277,7 +277,7 @@ pub(crate) fn fixup_syntax( }, ast::RecordExprField(it) => { if let Some(colon) = it.colon_token() { - if it.name_ref().is_some() { + if it.name_ref().is_some() && it.expr().is_none() { append.insert(colon.into(), vec![ Leaf::Ident(Ident { text: "__ra_fixup".into(), @@ -843,6 +843,20 @@ fn foo () {R {f : __ra_fixup}} ) } + #[test] + fn no_fixup_record_ctor_field() { + check( + r#" +fn foo() { + R { f: a } +} +"#, + expect![[r#" +fn foo () {R {f : a}} +"#]], + ) + } + #[test] fn fixup_arg_list() { check(