Skip to content

chore: add #[non_exhaustive] to remaining public structs#768

Open
DaleSeo wants to merge 3 commits intomainfrom
chore/non-exhaustive-missing-structs
Open

chore: add #[non_exhaustive] to remaining public structs#768
DaleSeo wants to merge 3 commits intomainfrom
chore/non-exhaustive-missing-structs

Conversation

@DaleSeo
Copy link
Member

@DaleSeo DaleSeo commented Mar 22, 2026

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_structs and clippy::exhaustive_enums as warn in Cargo.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 use Default or constructor methods, so the practical impact should be limited. For OAuthClientConfig, which had no constructor, a new() builder was added.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@DaleSeo DaleSeo self-assigned this Mar 22, 2026
@github-actions github-actions bot added T-test Testing related changes T-core Core library changes T-examples Example code changes T-handler Handler implementation changes T-transport Transport layer changes labels Mar 22, 2026
@github-actions github-actions bot added T-service Service layer changes T-dependencies Dependencies related changes T-config Configuration file changes T-model Model/data structure changes labels Mar 22, 2026
@DaleSeo DaleSeo force-pushed the chore/non-exhaustive-missing-structs branch from bba98bd to 7a87bc3 Compare March 22, 2026 20:06
@DaleSeo DaleSeo force-pushed the chore/non-exhaustive-missing-structs branch from 7a87bc3 to 6d411ae Compare March 22, 2026 21:20
@DaleSeo DaleSeo marked this pull request as ready for review March 22, 2026 22:17
@DaleSeo DaleSeo requested a review from a team as a code owner March 22, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-dependencies Dependencies related changes T-examples Example code changes T-handler Handler implementation changes T-model Model/data structure changes T-service Service layer changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant