Skip to content

Commit

Permalink
fix clippy + add cli test
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver T <[email protected]>
  • Loading branch information
snOm3ad committed Sep 20, 2023
1 parent f6ce82c commit 632abe6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,16 +523,16 @@ impl TryToTokens for ast::Export {
argtys.push(&*arg.ty);
let i = i + offset;
let ident = Ident::new(&format!("arg{}", i), Span::call_site());
fn unwrap_nested_types(ty: &Box<syn::Type>) -> &Box<syn::Type> {
match &**ty {
fn unwrap_nested_types(ty: &syn::Type) -> &syn::Type {
match &ty {
syn::Type::Group(syn::TypeGroup { ref elem, .. }) => unwrap_nested_types(elem),
syn::Type::Paren(syn::TypeParen { ref elem, .. }) => unwrap_nested_types(elem),
_ => ty,
}
}
let ty = unwrap_nested_types(&arg.ty);

match &**ty {
match &ty {
syn::Type::Reference(syn::TypeReference {
mutability: Some(_),
elem,
Expand Down
26 changes: 26 additions & 0 deletions crates/cli/tests/wasm-bindgen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,29 @@ fn constructor_cannot_return_option_struct() {
.wasm_bindgen("--target web");
cmd.assert().failure();
}

#[test]
fn unwrap_types_of_macro_rules_exports() {
let (mut cmd, _out_dir) = Project::new("unwrap_types_of_macro_rules_exports")
.file(
"src/lib.rs",
r#"
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Test;
macro_rules! my_export {
($i: ident, $s: ty) => {
#[wasm_bindgen]
pub fn $i(s: $s) {
}
}
}
my_export!(foo, &Test);
"#,
)
.wasm_bindgen("--target web");
cmd.assert().success();
}

0 comments on commit 632abe6

Please sign in to comment.