Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 181a6d7

Browse files
tinaunYamakaky
authored andcommitted
added hidden nonexaustive variant
fixes #182
1 parent ddd094e commit 181a6d7

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Change last rust version supported to 1.14
44
- [Cache whether RUST_BACKTRACE is enabled in a relaxed atomic static.](https://github.com/rust-lang-nursery/error-chain/pull/210)
55
- [Mask the `quick_error` macro from the doc](https://github.com/rust-lang-nursery/error-chain/pull/210)
6+
- [Make generated `ErrorKind` enums non-exhaustive](https://github.com/rust-lang-nursery/error-chain/pull/193)
67

78
# 0.11.0-rc.2
89

@@ -27,7 +28,7 @@
2728

2829
# 0.8.1
2930

30-
- Add crates.io categorie.
31+
- Add crates.io category.
3132

3233
# 0.8.0
3334

src/impl_error_chain_kind.rs

+7
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ macro_rules! impl_error_chain_kind {
201201
$(#[$imeta])*
202202
$iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*,
203203
)*
204+
205+
#[doc(hidden)]
206+
__Nonexhaustive {}
204207
}
205208
};
206209
// Private enum (Queue Empty)
@@ -279,6 +282,8 @@ macro_rules! impl_error_chain_kind {
279282
display_fn(self, fmt)
280283
}
281284
)*
285+
286+
_ => Ok(())
282287
}
283288
}
284289
}
@@ -326,6 +331,8 @@ macro_rules! impl_error_chain_kind {
326331
{$( $funcs )*})
327332
}
328333
)*
334+
335+
_ => "",
329336
}
330337
}
331338
}

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@
348348
//! match Error::from("error!") {
349349
//! Error(ErrorKind::InvalidToolchainName(_), _) => { }
350350
//! Error(ErrorKind::Msg(_), _) => { }
351+
//! _ => { }
351352
//! }
352353
//! # }
353354
//! ```

tests/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,8 @@ fn error_patterns() {
485485

486486
// Tuples look nice when matching errors
487487
match Error::from("Test") {
488-
Error(ErrorKind::Msg(_), _) => {}
488+
Error(ErrorKind::Msg(_), _) => {},
489+
_ => {},
489490
}
490491
}
491492

0 commit comments

Comments
 (0)