Skip to content
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

idl: Add #[non_exhaustive] to IDL enums #2890

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ The minor version will be incremented upon a breaking change and the patch versi
- ts: Remove discriminator functions ([#2824](https://github.com/coral-xyz/anchor/pull/2824)).
- ts: Remove `programId` parameter of the `Program` constructor ([#2864](https://github.com/coral-xyz/anchor/pull/2864)).
- idl, syn: Move IDL types from the `anchor-syn` crate to the new IDL crate ([#2882](https://github.com/coral-xyz/anchor/pull/2882)).
- idl: Add `#[non_exhaustive]` to IDL enums ([#2890](https://github.com/coral-xyz/anchor/pull/2890)).

## [0.29.0] - 2023-10-16

Expand Down
1 change: 1 addition & 0 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2964,6 +2964,7 @@ fn deserialize_idl_type_to_json(
deserialize_idl_defined_type_to_json(parent_idl, name, data)?
}
IdlType::Generic(generic) => json!(generic),
_ => unimplemented!("{idl_type:?}"),
})
}

Expand Down
3 changes: 3 additions & 0 deletions idl/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub struct IdlTypeDef {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum IdlSerialization {
#[default]
Borsh,
Expand All @@ -188,6 +189,7 @@ pub enum IdlSerialization {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(tag = "kind", rename_all = "lowercase")]
#[non_exhaustive]
pub enum IdlRepr {
Rust(IdlReprModifier),
C(IdlReprModifier),
Expand Down Expand Up @@ -266,6 +268,7 @@ pub enum IdlGenericArg {

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum IdlType {
Bool,
U8,
Expand Down
2 changes: 2 additions & 0 deletions lang/attribute/program/src/declare_program/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub fn convert_idl_type_to_str(ty: &IdlType) -> String {
.map(|generics| format!("{name}<{generics}>"))
.unwrap_or(name.into()),
IdlType::Generic(ty) => ty.into(),
_ => unimplemented!("{ty:?}"),
}
}

Expand Down Expand Up @@ -151,6 +152,7 @@ pub fn convert_idl_type_def_to_ts(
IdlRepr::Rust(_) => "Rust",
IdlRepr::C(_) => "C",
IdlRepr::Transparent => "transparent",
_ => unimplemented!("{repr:?}"),
};
let kind = format_ident!("{kind}");

Expand Down
Loading