You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
codegen: an attribute rule (type_attribute, field_attribute, oneof_struct_field_attribute, …) that matches nothing produces no warning #697
The six attribute options (type_attribute, message_attribute, enum_attribute, oneof_attribute, field_attribute, oneof_struct_field_attribute) accept a path that matches no generated element. The attribute is left off and the build succeeds with no diagnostic:
buffa_build::Config::new().field_attribute(".my.pkg.Mesage.secret","#[serde(skip)]")// typo.oneof_struct_field_attribute(".my.pkg.Msg.kind.text","#[serde(skip)]")// variant path, not the oneof
For #[serde(skip)] or #[deprecated] the missing attribute changes behaviour. The oneof_struct_field_attribute rustdoc states the gap: a variant path "has no effect, and the build does not warn about it".
The other path-scoped options warn from generate_with_diagnostics (buffa-codegen/src/lib.rs): FieldTypeRuleMatchedNothing, SkipDebugRuleMatchedNothing, PreserveUnknownFieldsRuleMatchedNothing, DenyUnknownJsonFieldsRuleMatchedNothing, CodecStrategyRuleMatchedNothing, FeatureOverrideMatchedNothing, ExcludePackageMatchedNothing. The attribute lists are read only by CodeGenContext::matching_attributes (buffa-codegen/src/context.rs), once per element, and that function does not record which rules matched.
Each list has its own target set: messages, enums and oneofs for type_attributes; messages for message_attributes; enums for enum_attributes; oneofs for oneof_attributes and oneof_struct_field_attributes; fields and oneof variants (.pkg.Msg.oneof.variant) for field_attributes.
Related: matching_attributes parses an attribute string only when its rule matches, so a malformed attribute on a rule that matches nothing is not reported as InvalidCustomAttribute. #619 is the same gap for box_type_in / unbox_oneof_in.
Activity