-
Notifications
You must be signed in to change notification settings - Fork 985
Open
Labels
A-macrosArea: macros (procedural macros, macro_rules! macros, etc.)Area: macros (procedural macros, macro_rules! macros, etc.)C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-invalid-codeIssue: formatting causes compile-pass code to compile-failIssue: formatting causes compile-pass code to compile-failSO-use_field_init_shorthandStable Option: use_field_init_shorthandStable Option: use_field_init_shorthand
Description
I am using the seq macro from the winnow library.
The macro takes a struct literal, but instead of passing in the values for the fields, you pass in functions which it uses to initialize the fields.
If the name of the function is the same as the name of the field, rustfmt tries to shorten it to struct literal shorthand which is not valid.
fn name<'i>(input: &mut Stream<'i>) -> ModalResult<&'i str> {
todo!()
}
fn preconditions<'i>(input: &mut Stream<'i>) -> ModalResult<Preconditions<'i>> {
todo!()
}
// this...
seq!(PrimitiveTask {
name: name,
preconditions: preconditions,
});
// ...is shortened to this. It does not compile.
seq!(PrimitiveTask { name, preconditions });
// I am using this as a workaround
seq!(PrimitiveTask {
name: { name },
preconditions: { preconditions },
});The seq macro is a bit complex, so I am not sure what a minimal reproduction would look like.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-macrosArea: macros (procedural macros, macro_rules! macros, etc.)Area: macros (procedural macros, macro_rules! macros, etc.)C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICECategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEI-invalid-codeIssue: formatting causes compile-pass code to compile-failIssue: formatting causes compile-pass code to compile-failSO-use_field_init_shorthandStable Option: use_field_init_shorthandStable Option: use_field_init_shorthand