Skip to content

Commit f63ae06

Browse files
authored
Fix rust-analyzer "Go to Definition" inside #[builder] functions (#385)
1 parent 8e288cb commit f63ae06

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

bon-macros/src/builder/builder_gen/start_fn.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ impl super::BuilderGenCtx {
109109
format_ident!("elidable_lifetime_names")
110110
};
111111

112-
// Construct using a span which links to our original implementation.
113-
// This ensures rustdoc doesn't just link every method to the macro
114-
// callsite.
115-
syn::parse_quote_spanned! {self.start_fn.span=>
112+
let mut start_fn: syn::ItemFn = syn::parse_quote! {
116113
#(#docs)*
117114
#[inline(always)]
118115
#[allow(
@@ -143,6 +140,13 @@ impl super::BuilderGenCtx {
143140
__unsafe_private_named: #named_members_field_init,
144141
}
145142
}
146-
}
143+
};
144+
145+
let span = self.start_fn.span;
146+
147+
start_fn.sig.fn_token = syn::Token![fn](span);
148+
start_fn.block.brace_token = syn::token::Brace(span);
149+
150+
start_fn
147151
}
148152
}

0 commit comments

Comments
 (0)