in starlark_derive/src/render.rs [431:460]
fn render_signature_arg(arg: &StarArg) -> TokenStream {
let span = arg.span;
let mut name_str_full = (if arg.by_ref { "$" } else { "" }).to_owned();
name_str_full += &ident_string(&arg.name);
let name_str = name_str_full.trim_matches('_');
if arg.is_args() {
assert!(arg.default.is_none(), "Can't have *args with a default");
quote_spanned! { span=> __signature.args();}
} else if arg.is_kwargs() {
assert!(arg.default.is_none(), "Can't have **kwargs with a default");
quote_spanned! { span=> __signature.kwargs();}
} else if arg.is_this() {
quote_spanned! { span=> }
} else if arg.is_option() {
quote_spanned! { span=> __signature.optional(#name_str);}
} else if let Some(default) = &arg.default {
// For things that are type Value, we put them on the frozen heap.
// For things that aren't type value, use optional and then next_opt/unwrap
// to avoid the to/from value conversion.
if arg.is_value() {
quote_spanned! { span=> __signature.defaulted(#name_str, globals_builder.alloc(#default));}
} else {
quote_spanned! { span=> __signature.optional(#name_str);}
}
} else {
quote_spanned! { span=> __signature.required(#name_str);}
}
}