-
Notifications
You must be signed in to change notification settings - Fork 0
Remove non_exhaustive from enum definitions #810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR removes the #[non_exhaustive] attribute from all generated Rust enum definitions to align with the design choice that enums should be exhaustive and fail at compile time when new variants are added. It also updates the enum code generator and records the change in the changelog.
Changes:
- Stopped emitting
#[non_exhaustive]on all generated enums in the Rust code generator. - Updated all test baselines (
enums.rsfiles) to reflect enums without#[non_exhaustive]. - Documented the change under the unreleased
0.33.1section of the changelog.
Reviewed changes
Copilot reviewed 2 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/typespec-rust/test/spector/type/property/value-types/src/generated/models/enums.rs |
Updates enum test baselines for value-type properties to remove #[non_exhaustive]. |
packages/typespec-rust/test/spector/type/property/optionality/src/generated/models/enums.rs |
Removes #[non_exhaustive] from literal union enums used in optionality tests. |
packages/typespec-rust/test/spector/type/enum/fixed/src/generated/models/enums.rs |
Makes fixed enum baseline (DaysOfWeekEnum) exhaustive by dropping #[non_exhaustive]. |
packages/typespec-rust/test/spector/type/enum/extensible/src/generated/models/enums.rs |
Makes extensible enum baseline (DaysOfWeekExtensibleEnum) exhaustive as well. |
packages/typespec-rust/test/spector/client/structure/two-operation-group/src/generated/models/enums.rs |
Removes #[non_exhaustive] from ClientType enum in two-operation-group client structure tests. |
packages/typespec-rust/test/spector/client/structure/renamed-operation/src/generated/models/enums.rs |
Same ClientType enum baseline update for renamed-operation client tests. |
packages/typespec-rust/test/spector/client/structure/multi-client/src/generated/models/enums.rs |
Same ClientType enum baseline update for multi-client structure tests. |
packages/typespec-rust/test/spector/client/structure/default/src/generated/models/enums.rs |
Same ClientType enum baseline update for default client structure tests. |
packages/typespec-rust/test/spector/client/structure/client-operation-group/src/generated/models/enums.rs |
Same ClientType enum baseline update for client-operation-group structure tests. |
packages/typespec-rust/test/spector/client/naming/src/generated/models/enums.rs |
Removes #[non_exhaustive] from ClientExtensibleEnum and ExtensibleEnum naming tests. |
packages/typespec-rust/test/spector/client/enum-conflict/src/generated/models/enums.rs |
Makes SecondStatus and Status enums exhaustive by dropping #[non_exhaustive]. |
packages/typespec-rust/test/spector/azure/resource-manager/resources/src/generated/models/enums.rs |
Updates RM resources enum baselines (CreatedByType, ProvisioningState, ResourceProvisioningState) to be exhaustive. |
packages/typespec-rust/test/spector/azure/resource-manager/operation-templates/src/generated/models/enums.rs |
Removes #[non_exhaustive] from several operation-template enums (e.g., ActionType, CheckNameAvailabilityReason, Origin, ResourceProvisioningState). |
packages/typespec-rust/test/spector/azure/resource-manager/method-subscription-id/src/generated/models/enums.rs |
Makes ActionType, CreatedByType, Origin, and ResourceProvisioningState enums exhaustive. |
packages/typespec-rust/test/spector/azure/resource-manager/large-header/src/generated/models/enums.rs |
Removes #[non_exhaustive] from ResourceProvisioningState enum in large-header tests. |
packages/typespec-rust/test/spector/azure/resource-manager/common-properties/src/generated/models/enums.rs |
Drops #[non_exhaustive] from CreatedByType and ManagedServiceIdentityType enum baselines. |
packages/typespec-rust/test/spector/azure/example/basic/src/generated/models/enums.rs |
Makes example Enum exhaustive by removing #[non_exhaustive]. |
packages/typespec-rust/test/spector/azure/core/traits/src/generated/models/enums.rs |
Removes #[non_exhaustive] from RepeatabilityResult enum in core traits tests. |
packages/typespec-rust/test/spector/azure/core/page/src/generated/models/enums.rs |
Makes page-related extensible enums (e.g., ListItemInputExtensibleEnum) exhaustive in tests. |
packages/typespec-rust/test/spector/azure/core/lro/standard/src/generated/models/enums.rs |
Removes #[non_exhaustive] from OperationState enum baseline for standard LRO tests. |
packages/typespec-rust/test/spector/azure/core/lro/rpc/src/generated/models/enums.rs |
Same OperationState enum update for RPC LRO tests. |
packages/typespec-rust/test/sdk/keyvault_secrets/src/generated/models/enums.rs |
Drops #[non_exhaustive] from Key Vault enums such as ContentType and DeletionRecoveryLevel. |
packages/typespec-rust/test/sdk/blob_storage/src/generated/models/enums.rs |
Removes #[non_exhaustive] from all Blob Storage-related enums (e.g., AccessTier, AccountKind, BlobType, SkuName). |
packages/typespec-rust/test/sdk/appconfiguration/src/generated/models/enums.rs |
Makes App Configuration enums (e.g., CompositionType, various *ContentType, OperationState, SnapshotStatus) exhaustive. |
packages/typespec-rust/test/other/serde_tests/src/generated/models/enums.rs |
Updates serde-related enum baselines (e.g., ExtensibleValues) to no longer use #[non_exhaustive]. |
packages/typespec-rust/test/other/misc_tests/src/generated/models/enums.rs |
Removes #[non_exhaustive] from misc test enums such as Colors, HasCollidingNames, and Indices. |
packages/typespec-rust/test/other/lro/src/generated/models/enums.rs |
Makes enum S exhaustive for other LRO tests. |
packages/typespec-rust/test/other/enum_path_params/src/generated/models/enums.rs |
Drops #[non_exhaustive] from path-parameter enums (ExtensibleShape, ExtensibleValues, FixedShape, FixedValues, NumericValues). |
packages/typespec-rust/src/codegen/enums.ts |
Changes enum code generation to stop emitting the #[non_exhaustive] attribute for any generated enum. |
packages/typespec-rust/CHANGELOG.md |
Documents that enums are no longer marked #[non_exhaustive] in the upcoming 0.33.1 release. |
634955f to
f5cee42
Compare
Fixes #809