chore: add #[non_exhaustive] to remaining public structs#768
Open
chore: add #[non_exhaustive] to remaining public structs#768
Conversation
bba98bd to
7a87bc3
Compare
7a87bc3 to
6d411ae
Compare
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.
Motivation and Context
PR #715 began the effort to mark public types as
#[non_exhaustive]ahead of the 1.0 release, but missed several structs and enums across transport, service, handler, auth, and task_manager modules. Without this attribute, any new field or variant addition is a semver-breaking change for downstream consumers.To prevent this class of omission from recurring, this PR also enables
clippy::exhaustive_structsandclippy::exhaustive_enumsaswarninCargo.toml. Types that are intentionally exhaustive (unit structs, newtype wrappers, and protocol-spec model types) are annotated with#[allow]. Any new public struct or enum added without#[non_exhaustive]will now produce a Clippy warning.How Has This Been Tested?
All the existing tests have passed.
Breaking Changes
Yes. Adding
#[non_exhaustive]to structs that previously had all public fields is technically a semver-breaking change. However, this is the same intentional tradeoff made in #715: accepting a one-time break now to prevent repeated breaks every time a field is added in the future. Most consumers already useDefaultor constructor methods, so the practical impact should be limited. ForOAuthClientConfig, which had no constructor, anew()builder was added.Types of changes
Checklist