Caused by rust-lang/rust#72388; this has more details.
Here's a (kind of, but not really) minified test case:
macro_rules! import_macro {
($(($rust:ident, $js:ident, $i:ident))*) => ($(
#[wasm_bindgen]
pub fn $rust(a: &[$i]) -> Vec<$i> {
$js(a, Some(a), None)
}
)*)
}
import_macro! {
(import_rust_i8, import_js_i8, i8)
}
#[wasm_bindgen] tries to parse the function as a syn::ItemFn which fails on the function's block (specifically on the ( after $js). As mentioned in the linked issue, as best as I can tell, this happens because trailer_expr (in expr.rs) returns if it sees a group which causes Block::parse_within to only see $js rather than the whole expression. Block::parse_within then expects a semicolon after $js (since it's not the last thing in the block) which it doesn't see and so it errors.
As mentioned in the linked issue's thread, removing the token::Group check in trailer_expr seems to fix this problem but I don't know if this will cause other problems; I'm not very familiar with syn's internals.
I noticed #832 altered that exact check; I tested again with 1.0.26 and I still get the same error.
Also, slightly unrelated, but would it be correct for the error here to be "expected semicolon"?
Caused by rust-lang/rust#72388; this has more details.
Here's a (kind of, but not really) minified test case:
#[wasm_bindgen]tries to parse the function as asyn::ItemFnwhich fails on the function's block (specifically on the(after$js). As mentioned in the linked issue, as best as I can tell, this happens becausetrailer_expr(inexpr.rs) returns if it sees a group which causesBlock::parse_withinto only see$jsrather than the whole expression.Block::parse_withinthen expects a semicolon after$js(since it's not the last thing in the block) which it doesn't see and so it errors.As mentioned in the linked issue's thread, removing the
token::Groupcheck intrailer_exprseems to fix this problem but I don't know if this will cause other problems; I'm not very familiar withsyn's internals.I noticed #832 altered that exact check; I tested again with 1.0.26 and I still get the same error.
Also, slightly unrelated, but would it be correct for the error here to be "expected semicolon"?