Skip to content

Commit 4cda18f

Browse files
authored
Merge pull request #1338 from alexcrichton/fix-nom
Workaround an upstream `nom` bug
2 parents 90c3196 + 5192b95 commit 4cda18f

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)