Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments to enum constructors too with @doc #239

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3344,6 +3344,9 @@ impl GenerationScope {
let variant_arg = variant.name_as_var();
let mut new_func = codegen::Function::new(&format!("new_{variant_arg}"));
new_func.vis("pub");
if let Some(doc) = &variant.doc {
new_func.doc(doc);
}
let can_fail = variant.rust_type().needs_bounds_check_if_inlined(types);
if !variant.rust_type().is_fixed_value() {
new_func.arg(&variant_arg, variant.rust_type().for_wasm_param(types));
Expand Down Expand Up @@ -6225,7 +6228,9 @@ fn codegen_group_choices(
// TODO: verify if variant.serialize_as_embedded_group impacts ctor generation
let mut new_func = codegen::Function::new(&format!("new_{}", variant.name_as_var()));
new_func.vis("pub");

if let Some(doc) = &variant.doc {
new_func.doc(doc);
}
let mut output_comma = false;
// We only want to generate Variant::new() calls when we created a special struct
// for the variant, which happens in the general case for multi-field group choices
Expand Down Expand Up @@ -6995,6 +7000,9 @@ fn generate_enum(
// new (particularly useful if we have encoding variables)
let mut new_func = codegen::Function::new(&format!("new_{variant_var_name}"));
new_func.vis("pub");
if let Some(doc) = &variant.doc {
new_func.doc(doc);
}
let mut output_comma = false;
let (mut init_fields, can_fail) = match &variant.data {
EnumVariantData::RustType(ty) => {
Expand Down
Loading