Skip to content

Commit 5390654

Browse files
Correctly consume tokens when parsing js_namespace (#2510)
* Correctly consume tokens when parsing `js_namespace` `syn` < 1.0.66 would consume the `AnyIdent` anyway while trying to parse the `ExprArray`. Now due to a refactoring they did, they (correctly) leave the `ParseBuffer` untouched if the input is not a valid `ExprArray`, so we should avoid forking the input buffer and just use the same for both tries, otherwise the unwanted tokens left in there would make `Punctuated` break soon after. Fixes #2508 * Update nightly used on CI * Update syn version dependency Co-authored-by: Alex Crichton <[email protected]>
1 parent 0cec406 commit 5390654

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
steps:
8888
- template: ci/azure-install-rust.yml
8989
parameters:
90-
toolchain: nightly-2021-01-23
90+
toolchain: nightly-2021-03-28
9191
- template: ci/azure-install-node.yml
9292
- script: cargo test --target wasm32-unknown-unknown --features nightly --test wasm
9393

crates/macro-support/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extra-traits = ["syn/extra-traits"]
1717
strict-macro = []
1818

1919
[dependencies]
20-
syn = { version = '1.0.27', features = ['visit', 'full'] }
20+
syn = { version = '1.0.67', features = ['visit', 'full'] }
2121
quote = '1.0'
2222
proc-macro2 = "1.0"
2323
wasm-bindgen-backend = { path = "../backend", version = "=0.2.72" }

crates/macro-support/src/parser.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,6 @@ impl Parse for BindgenAttr {
299299

300300
(@parser $variant:ident(Span, Vec<String>, Vec<Span>)) => ({
301301
input.parse::<Token![=]>()?;
302-
let input_before_parse = input.fork();
303302
let (vals, spans) = match input.parse::<syn::ExprArray>() {
304303
Ok(exprs) => {
305304
let mut vals = vec![];
@@ -320,7 +319,7 @@ impl Parse for BindgenAttr {
320319
(vals, spans)
321320
},
322321
Err(_) => {
323-
let ident = input_before_parse.parse::<AnyIdent>()?.0;
322+
let ident = input.parse::<AnyIdent>()?.0;
324323
(vec![ident.to_string()], vec![ident.span()])
325324
}
326325
};

0 commit comments

Comments
 (0)