Skip to content

Commit 5192b95

Browse files
committed
Workaround an upstream nom bug
This commit works around rust-bakery/nom#843 where the API of the `nom` crate changes based on feature selection, meaning we need to be compatible even if another crate in the crate graph enables a feature. Ideally this'd be fixed in upstream `nom`, and it looks like it will in the next major version! For now a local catch-all directive should help out.
1 parent 90c3196 commit 5192b95

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/webidl/src/lib.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ fn parse(webidl_source: &str, allowed_types: Option<&[&str]>) -> Result<Program>
6868
.context(ErrorKind::ParsingWebIDLSource)
6969
.into(),
7070
weedle::Err::Error(cx) | weedle::Err::Failure(cx) => {
71+
// Note that #[allow] here is a workaround for Geal/nom#843
72+
// because the `Context` type here comes from `nom` and if
73+
// something else in our crate graph enables the
74+
// `verbose-errors` feature then we need to still compiled
75+
// against the changed enum definition.
76+
#[allow(unreachable_patterns)]
7177
let remaining = match cx {
72-
weedle::Context::Code(remaining, _) => remaining,
78+
weedle::Context::Code(remaining, _) => remaining.len(),
79+
_ => 0,
7380
};
74-
let pos = webidl_source.len() - remaining.len();
81+
let pos = webidl_source.len() - remaining;
7582
format_err!("failed to parse WebIDL")
7683
.context(ErrorKind::ParsingWebIDLSourcePos(pos))
7784
.into()

0 commit comments

Comments
 (0)