Repository navigation
feat(codegen): warn when a custom attribute rule matches no generated element - #848
Open
dev-burnern wants to merge 1 commit into
Open
dev-burnern wants to merge 1 commit into
dev-burnern wants to merge 1 commit into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #697
Summary
generate_with_diagnosticsnow emitsCodeGenWarning::AttributeRuleMatchedNothing { rule, option }for any custom attribute rule intype_attributes,field_attributes,message_attributes,enum_attributes,oneof_attributes, oroneof_struct_field_attributesthat matched no generated element during the run.buffa-codegen/src/context.rs:AttributeOptioncovering all six attribute lists and aRefCell<[Vec<bool>; 6]>match tracker onCodeGenContext.CodeGenContext::matching_attributes_for(option, fqn)(used by all nine call sites acrossenumeration.rs,message.rs, andoneof.rs) to record matched rules as elements are generated — ensuring exact agreement with what codegen actually emits (extern-mapped types, excluded packages, synthetic proto3-optional oneofs, and wrong-kind paths such as variant paths inoneof_struct_field_attributesall warn automatically).CodeGenContext::warn_unmatched_attributes()called at the end ofgenerate_with_diagnostics().buffa-codegen/src/lib.rs:CodeGenWarning::AttributeRuleMatchedNothing { rule, option }(#[non_exhaustive]) withDisplayformatting and unit tests covering all six attribute options (both matching rules with 0 warnings and unmatched rules)..changes/unreleased/added-20261122-181800.yaml: adds the changelog fragment.Verification
cargo fmt --check— passedcargo test -p buffa-codegen --lib— 852 passed, 0 failedcargo clippy -p buffa-codegen --all-targets -- -D warnings— passed (0 warnings)RUSTDOCFLAGS="-D warnings" cargo doc -p buffa-codegen --no-deps— passed (0 warnings)