From 5192b95bf3d03190c26432b0b8358311e23d314b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 12 Mar 2019 12:22:24 -0700 Subject: [PATCH] Workaround an upstream `nom` bug This commit works around Geal/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. --- crates/webidl/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/webidl/src/lib.rs b/crates/webidl/src/lib.rs index ab61ed56e7e..e005b169182 100644 --- a/crates/webidl/src/lib.rs +++ b/crates/webidl/src/lib.rs @@ -68,10 +68,17 @@ fn parse(webidl_source: &str, allowed_types: Option<&[&str]>) -> Result .context(ErrorKind::ParsingWebIDLSource) .into(), weedle::Err::Error(cx) | weedle::Err::Failure(cx) => { + // Note that #[allow] here is a workaround for Geal/nom#843 + // because the `Context` type here comes from `nom` and if + // something else in our crate graph enables the + // `verbose-errors` feature then we need to still compiled + // against the changed enum definition. + #[allow(unreachable_patterns)] let remaining = match cx { - weedle::Context::Code(remaining, _) => remaining, + weedle::Context::Code(remaining, _) => remaining.len(), + _ => 0, }; - let pos = webidl_source.len() - remaining.len(); + let pos = webidl_source.len() - remaining; format_err!("failed to parse WebIDL") .context(ErrorKind::ParsingWebIDLSourcePos(pos)) .into()