fix: remove #[non_exhaustive] from ValidationResult struct#545
Merged
fix: remove #[non_exhaustive] from ValidationResult struct#545
Conversation
All fields were already public, so the attribute only prevented struct literal construction from outside the crate. Added a regression test that constructs ValidationResult via struct literal to guard against re-introduction.
…sts, fix changelog format - doc comment on ValidationResult now explains struct literal is supported and notes the forward-compatibility implication for future field additions - add validation_result_implements_required_traits (Debug + Clone contract guards) - add validation_result_allows_exhaustive_destructuring (symmetric guard to literal test) - clarify guard comment in struct literal test to mention field additions also break it - CHANGELOG entry: use (#487) format, remove editorial phrasing
… in destructure test
Contributor
There was a problem hiding this comment.
Pull request overview
Removes #[non_exhaustive] from agnix_core::ValidationResult to allow struct literal construction and exhaustive destructuring by downstream crates, aligning the type’s semantics with its already-public fields and existing constructor/builder patterns.
Changes:
- Removes
#[non_exhaustive]fromValidationResultand updates its rustdoc to clarify forward-compat implications. - Adds API-contract integration tests that ensure
ValidationResultstaysDebug + Cloneand remains constructible/destructurable from external crates. - Documents the API change in the changelog under
[Unreleased].
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/agnix-core/src/pipeline.rs | Drops #[non_exhaustive] on ValidationResult and updates documentation to reflect the new guarantees/tradeoffs. |
| crates/agnix-core/tests/api_contract.rs | Adds compile-time integration tests guarding struct literal construction and exhaustive destructuring, plus required trait impls. |
| CHANGELOG.md | Notes the API change in the Unreleased “Changed” section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
#[non_exhaustive]from theValidationResultstruct inagnix-corediagnostics,files_checked,validation_time_ms,validator_factories_registered) are alreadypub, so the attribute was only preventing struct literal construction and exhaustive destructuring from external crates - patterns no consumer needs sinceValidationResultis always a return value fromvalidate_project()ValidationResult::new()constructor and builder methods remain as the idiomatic construction pathValidationOutcomeandConfigErrorenums correctly keep their#[non_exhaustive](different semantics for enums)Changes
crates/agnix-core/src/pipeline.rs: Remove#[non_exhaustive], update doc comment to mention struct literal is now supported and note forward-compatibility implicationcrates/agnix-core/tests/api_contract.rs: Add 3 new tests:validation_result_implements_required_traits- pins Debug + Clone as API contractvalidation_result_allows_struct_literal_construction- compile-time guard against re-adding#[non_exhaustive]validation_result_allows_exhaustive_destructuring- symmetric guard for exhaustive patternsCHANGELOG.md: Document change under[Unreleased] > ### ChangedTest Plan
cargo checkpassescargo test -p agnix-core --test api_contract- all 53 tests pass including 3 newcargo test- full suite passes (3400+ tests)Closes #487