Skip to content

Commit eb04cf2

Browse files
authored
Upgrade weedle to v0.11 (#2024)
1 parent 381660c commit eb04cf2

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

crates/webidl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ proc-macro2 = "1.0"
2020
quote = '1.0'
2121
syn = { version = '1.0', features = ['full'] }
2222
wasm-bindgen-backend = { version = "=0.2.58", path = "../backend" }
23-
weedle = "0.10"
23+
weedle = "0.11"

crates/webidl/src/first_pass.rs

+7
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,13 @@ impl<'src> FirstPass<'src, (&'src str, ApiStability)> for weedle::interface::Int
475475
.push(const_);
476476
Ok(())
477477
}
478+
InterfaceMember::Constructor(_) => {
479+
log::warn!(
480+
"Unsupported WebIDL Constructor interface member: {:?}",
481+
self
482+
);
483+
Ok(())
484+
}
478485
InterfaceMember::Iterable(_iterable) => {
479486
log::warn!("Unsupported WebIDL iterable interface member: {:?}", self);
480487
Ok(())

crates/webidl/src/lib.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use wasm_bindgen_backend::TryToTokens;
3737
use weedle::attribute::ExtendedAttributeList;
3838
use weedle::dictionary::DictionaryMember;
3939
use weedle::interface::InterfaceMember;
40+
use weedle::Parse;
4041

4142
struct Program {
4243
main: ast::Program,
@@ -74,26 +75,19 @@ impl Default for ApiStability {
7475
}
7576

7677
fn parse_source(source: &str) -> Result<Vec<weedle::Definition>> {
77-
weedle::parse(source).map_err(|e| {
78-
match &e {
79-
weedle::Err::Incomplete(needed) => anyhow::anyhow!("needed {:?} more bytes", needed),
80-
weedle::Err::Error(cx) | weedle::Err::Failure(cx) => {
81-
// Note that #[allow] here is a workaround for Geal/nom#843
82-
// because the `Context` type here comes from `nom` and if
83-
// something else in our crate graph enables the
84-
// `verbose-errors` feature then we need to still compiled
85-
// against the changed enum definition.
86-
#[allow(unreachable_patterns)]
87-
let remaining = match cx {
88-
weedle::Context::Code(remaining, _) => remaining.len(),
89-
_ => 0,
90-
};
91-
let pos = source.len() - remaining;
92-
93-
WebIDLParseError(pos).into()
94-
}
78+
match weedle::Definitions::parse(source) {
79+
Ok(("", parsed)) => Ok(parsed),
80+
81+
Ok((remaining, _))
82+
| Err(weedle::Err::Error((remaining, _)))
83+
| Err(weedle::Err::Failure((remaining, _))) => {
84+
Err(WebIDLParseError(source.len() - remaining.len()).into())
9585
}
96-
})
86+
87+
Err(weedle::Err::Incomplete(needed)) => {
88+
Err(anyhow::anyhow!("needed {:?} more bytes", needed))
89+
}
90+
}
9791
}
9892

9993
/// Parse a string of WebIDL source text into a wasm-bindgen AST.

0 commit comments

Comments
 (0)