Skip to content

Commit 4818a02

Browse files
committed
feat!: Mark all Error enums as non_exhaustive (#2056)
#2027 ended up being breaking due to adding a new variant to an error enum missing the `non_exhaustive` marker. This (breaking) PR makes sure all error enums have the flag. BREAKING CHANGE: Marked all Error enums as `non_exhaustive`
1 parent 7d9c650 commit 4818a02

File tree

9 files changed

+10
-0
lines changed

9 files changed

+10
-0
lines changed

hugr-core/src/extension.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ pub static EMPTY_REG: ExtensionRegistry = ExtensionRegistry {
378378
/// TODO: decide on failure modes
379379
#[derive(Debug, Clone, Error, PartialEq, Eq)]
380380
#[allow(missing_docs)]
381+
#[non_exhaustive]
381382
pub enum SignatureError {
382383
/// Name mismatch
383384
#[error("Definition name ({0}) and instantiation name ({1}) do not match.")]

hugr-core/src/hugr/serialize/upgrade.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use thiserror::Error;
22

33
#[derive(Debug, Error)]
4+
#[non_exhaustive]
45
pub enum UpgradeError {
56
#[error(transparent)]
67
Deserialize(#[from] serde_json::Error),

hugr-core/src/import.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use thiserror::Error;
3535

3636
/// Error during import.
3737
#[derive(Debug, Clone, Error)]
38+
#[non_exhaustive]
3839
pub enum ImportError {
3940
/// The model contains a feature that is not supported by the importer yet.
4041
/// Errors of this kind are expected to be removed as the model format and
@@ -75,6 +76,7 @@ pub enum ImportError {
7576

7677
/// Import error caused by incorrect order hints.
7778
#[derive(Debug, Clone, Error)]
79+
#[non_exhaustive]
7880
pub enum OrderHintError {
7981
/// Duplicate order hint key in the same region.
8082
#[error("duplicate order hint key {0}")]

hugr-model/src/v0/ast/resolve.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ impl<'a> Context<'a> {
362362

363363
/// Error that may occur in [`Module::resolve`].
364364
#[derive(Debug, Clone, Error)]
365+
#[non_exhaustive]
365366
pub enum ResolveError {
366367
/// Unknown variable.
367368
#[error("unknown var: {0}")]

hugr-model/src/v0/table/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ pub struct VarId(pub NodeId, pub VarIndex);
456456

457457
/// Errors that can occur when traversing and interpreting the model.
458458
#[derive(Debug, Clone, Error)]
459+
#[non_exhaustive]
459460
pub enum ModelError {
460461
/// There is a reference to a node that does not exist.
461462
#[error("node not found: {0}")]

hugr-passes/src/lower.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub fn replace_many_ops<S: Into<OpType>>(
3535
/// Errors produced by the [`lower_ops`] function.
3636
#[derive(Debug, Error)]
3737
#[error(transparent)]
38+
#[non_exhaustive]
3839
pub enum LowerError {
3940
/// Invalid subgraph.
4041
#[error("Subgraph formed by node is invalid: {0}")]

hugr-passes/src/non_local.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub fn nonlocal_edges<H: HugrView>(hugr: &H) -> impl Iterator<Item = (H::Node, I
2323
}
2424

2525
#[derive(Error, Debug, Clone, PartialEq, Eq)]
26+
#[non_exhaustive]
2627
pub enum NonLocalEdgesError<N> {
2728
#[error("Found {} nonlocal edges", .0.len())]
2829
Edges(Vec<(N, IncomingPort)>),

hugr-passes/src/replace_types/linearize.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub struct CallbackHandler<'a>(#[allow(dead_code)] &'a DelegatingLinearizer);
135135

136136
#[derive(Clone, Debug, thiserror::Error, PartialEq, Eq)]
137137
#[allow(missing_docs)]
138+
#[non_exhaustive]
138139
pub enum LinearizeError {
139140
#[error("Need copy/discard op for {_0}")]
140141
NeedCopyDiscard(Type),

hugr-passes/src/validation.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub enum ValidationLevel {
2525

2626
#[derive(Error, Debug, PartialEq)]
2727
#[allow(missing_docs)]
28+
#[non_exhaustive]
2829
pub enum ValidatePassError {
2930
#[error("Failed to validate input HUGR: {err}\n{pretty_hugr}")]
3031
InputError {

0 commit comments

Comments
 (0)