Skip to content

Commit 6e494d2

Browse files
JakobDegenfacebook-github-bot
authored andcommitted
module: Add signature to struct unconditionally
Summary: This is unused in some branches, but that's fine, constructing this happens just once. Makes the next diff simpler Reviewed By: IanChilds Differential Revision: D73726008 fbshipit-source-id: 970ccd04239c2656ccf117cbf16ae53d2241ebba
1 parent 771071c commit 6e494d2

File tree

2 files changed

+11
-19
lines changed
  • starlark_derive/src/module/render
  • starlark/src/__derive_refs

2 files changed

+11
-19
lines changed

starlark/src/__derive_refs/sig.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ pub fn parameter_spec(
5454
}
5555

5656
/// `ParametersSpec` for a function which accepts `&Arguments`.
57-
pub fn parameter_spec_for_arguments(name: &'static str) {
58-
parameter_spec(name, &[], &[], true, &[], true);
57+
pub fn parameter_spec_for_arguments(name: &'static str) -> ParametersSpec<FrozenValue> {
58+
parameter_spec(name, &[], &[], true, &[], true)
5959
}

starlark_derive/src/module/render/fun.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,15 @@ impl StarFun {
158158

159159
/// Fields and field initializers for the struct implementing the trait.
160160
fn struct_fields(&self) -> syn::Result<(Vec<syn::Field>, Vec<syn::FieldValue>)> {
161-
let signature = if let StarFunSource::Signature { .. } = self.source {
162-
Some(render_signature(self)?)
163-
} else {
164-
None
165-
};
166-
if let Some(signature) = signature {
167-
Ok((
168-
vec![syn::parse_quote! {
169-
signature: starlark::eval::ParametersSpec<starlark::values::FrozenValue>
170-
}],
171-
vec![syn::parse_quote! {
172-
signature: #signature
173-
}],
174-
))
175-
} else {
176-
Ok((Vec::new(), Vec::new()))
177-
}
161+
let signature = render_signature(self)?;
162+
Ok((
163+
vec![syn::parse_quote! {
164+
signature: starlark::eval::ParametersSpec<starlark::values::FrozenValue>
165+
}],
166+
vec![syn::parse_quote! {
167+
signature: #signature
168+
}],
169+
))
178170
}
179171

180172
/// Globals builder call to register the function.

0 commit comments

Comments
 (0)