Skip to content

fix: remove #[non_exhaustive] from ValidationResult struct#545

Merged
avifenesh merged 3 commits intomainfrom
fix/issue-487-validation-result-api
Feb 21, 2026
Merged

fix: remove #[non_exhaustive] from ValidationResult struct#545
avifenesh merged 3 commits intomainfrom
fix/issue-487-validation-result-api

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Removes #[non_exhaustive] from the ValidationResult struct in agnix-core
  • All four fields (diagnostics, files_checked, validation_time_ms, validator_factories_registered) are already pub, so the attribute was only preventing struct literal construction and exhaustive destructuring from external crates - patterns no consumer needs since ValidationResult is always a return value from validate_project()
  • The ValidationResult::new() constructor and builder methods remain as the idiomatic construction path
  • Note: ValidationOutcome and ConfigError enums 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 implication
  • crates/agnix-core/tests/api_contract.rs: Add 3 new tests:
    • validation_result_implements_required_traits - pins Debug + Clone as API contract
    • validation_result_allows_struct_literal_construction - compile-time guard against re-adding #[non_exhaustive]
    • validation_result_allows_exhaustive_destructuring - symmetric guard for exhaustive patterns
  • CHANGELOG.md: Document change under [Unreleased] > ### Changed

Test Plan

  • cargo check passes
  • cargo test -p agnix-core --test api_contract - all 53 tests pass including 3 new
  • cargo test - full suite passes (3400+ tests)

Closes #487

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
Copilot AI review requested due to automatic review settings February 21, 2026 00:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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] from ValidationResult and updates its rustdoc to clarify forward-compat implications.
  • Adds API-contract integration tests that ensure ValidationResult stays Debug + Clone and 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.

@avifenesh avifenesh merged commit b2ae805 into main Feb 21, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider removing #[non_exhaustive] from ValidationResult or making fields private

2 participants