Skip to content

Commit 12ee459

Browse files
committed
Add FutureProof variants to ParseError and SyntaxViolation
1 parent 0ab166e commit 12ee459

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/parser.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,17 @@ pub type ParseResult<T> = Result<T, ParseError>;
4949
macro_rules! simple_enum_error {
5050
($($name: ident => $description: expr,)+) => {
5151
/// Errors that can occur during parsing.
52+
///
53+
/// This may be extended in the future so exhaustive matching is
54+
/// discouraged with an unused variant.
5255
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
5356
pub enum ParseError {
5457
$(
5558
$name,
5659
)+
60+
/// Unused variant enable non-exhaustive matching
61+
#[doc(hidden)]
62+
__FutureProof,
5763
}
5864

5965
impl Error for ParseError {
@@ -62,6 +68,9 @@ macro_rules! simple_enum_error {
6268
$(
6369
ParseError::$name => $description,
6470
)+
71+
ParseError::__FutureProof => {
72+
unreachable!("Don't abuse the FutureProof!");
73+
}
6574
}
6675
}
6776
}
@@ -96,11 +105,17 @@ impl From<::idna::Errors> for ParseError {
96105
macro_rules! syntax_violation_enum {
97106
($($name: ident => $description: expr,)+) => {
98107
/// Non-fatal syntax violations that can occur during parsing.
108+
///
109+
/// This may be extended in the future so exhaustive matching is
110+
/// discouraged with an unused variant.
99111
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
100112
pub enum SyntaxViolation {
101113
$(
102114
$name,
103115
)+
116+
/// Unused variant enable non-exhaustive matching
117+
#[doc(hidden)]
118+
__FutureProof,
104119
}
105120

106121
impl SyntaxViolation {
@@ -109,6 +124,9 @@ macro_rules! syntax_violation_enum {
109124
$(
110125
SyntaxViolation::$name => $description,
111126
)+
127+
SyntaxViolation::__FutureProof => {
128+
unreachable!("Don't abuse the FutureProof!");
129+
}
112130
}
113131
}
114132
}

0 commit comments

Comments
 (0)