From bf7a4852489fea8bda7e0fd8bfbf5e105bfac9c8 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 21 Nov 2023 17:34:16 -0600 Subject: [PATCH] Add #[non_exhaustive] to error enums (#842) --- src/codec.rs | 1 + src/dp.rs | 1 + src/fft.rs | 1 + src/field.rs | 1 + src/flp.rs | 1 + src/idpf.rs | 1 + src/prng.rs | 1 + src/topology/ping_pong.rs | 1 + src/vdaf.rs | 1 + 9 files changed, 9 insertions(+) diff --git a/src/codec.rs b/src/codec.rs index 71f4f8ce5..07ee41de1 100644 --- a/src/codec.rs +++ b/src/codec.rs @@ -20,6 +20,7 @@ use std::{ /// An error that occurred during decoding. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum CodecError { /// An I/O error. #[error("I/O error")] diff --git a/src/dp.rs b/src/dp.rs index 506676dbb..6ed4f2afd 100644 --- a/src/dp.rs +++ b/src/dp.rs @@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize}; /// Errors propagated by methods in this module. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum DpError { /// Tried to use an invalid float as privacy parameter. #[error( diff --git a/src/fft.rs b/src/fft.rs index cac59a89e..612013eb4 100644 --- a/src/fft.rs +++ b/src/fft.rs @@ -10,6 +10,7 @@ use std::convert::TryFrom; /// An error returned by an FFT operation. #[derive(Debug, PartialEq, Eq, thiserror::Error)] +#[non_exhaustive] pub enum FftError { /// The output is too small. #[error("output slice is smaller than specified size")] diff --git a/src/field.rs b/src/field.rs index e3b82b07a..762bd68d6 100644 --- a/src/field.rs +++ b/src/field.rs @@ -39,6 +39,7 @@ pub use field255::Field255; /// Possible errors from finite field operations. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum FieldError { /// Input sizes do not match. #[error("input sizes do not match")] diff --git a/src/flp.rs b/src/flp.rs index 1912ebab1..ad7b0136e 100644 --- a/src/flp.rs +++ b/src/flp.rs @@ -61,6 +61,7 @@ pub mod types; /// Errors propagated by methods in this module. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum FlpError { /// Calling [`Type::prove`] returned an error. #[error("prove error: {0}")] diff --git a/src/idpf.rs b/src/idpf.rs index 2bb73f215..f83457173 100644 --- a/src/idpf.rs +++ b/src/idpf.rs @@ -30,6 +30,7 @@ use subtle::{Choice, ConditionallyNegatable, ConditionallySelectable, ConstantTi /// IDPF-related errors. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum IdpfError { /// Error from incompatible shares at different levels. #[error("tried to merge shares from incompatible levels")] diff --git a/src/prng.rs b/src/prng.rs index cb7d3a54c..54f8b127b 100644 --- a/src/prng.rs +++ b/src/prng.rs @@ -19,6 +19,7 @@ const BUFFER_SIZE_IN_ELEMENTS: usize = 32; /// Errors propagated by methods in this module. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum PrngError { /// Failure when calling getrandom(). #[error("getrandom: {0}")] diff --git a/src/topology/ping_pong.rs b/src/topology/ping_pong.rs index 7fdb501c9..b439cbcb9 100644 --- a/src/topology/ping_pong.rs +++ b/src/topology/ping_pong.rs @@ -15,6 +15,7 @@ use std::fmt::Debug; /// Errors emitted by this module. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum PingPongError { /// Error running prepare_init #[error("vdaf.prepare_init: {0}")] diff --git a/src/vdaf.rs b/src/vdaf.rs index f1c2b4f29..e1c37e75a 100644 --- a/src/vdaf.rs +++ b/src/vdaf.rs @@ -26,6 +26,7 @@ pub(crate) const VERSION: u8 = 7; /// Errors emitted by this module. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum VdafError { /// An error occurred. #[error("vdaf error: {0}")]