Skip to content

Commit ef22aba

Browse files
committed
Handle the possibility that the class name is in its own Group
rust-lang/rust#72388 makes this happen
1 parent 1e1cab6 commit ef22aba

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

crates/macro-support/src/parser.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
414414
let class = wasm.arguments.get(0).ok_or_else(|| {
415415
err_span!(self, "imported methods must have at least one argument")
416416
})?;
417-
let class = match &*class.ty {
417+
let mut class = match &*class.ty {
418418
syn::Type::Reference(syn::TypeReference {
419419
mutability: None,
420420
elem,
@@ -425,6 +425,9 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
425425
"first argument of method must be a shared reference"
426426
),
427427
};
428+
if let syn::Type::Group(syn::TypeGroup { elem, .. }) = class {
429+
class = elem;
430+
}
428431
let class_name = match *class {
429432
syn::Type::Path(syn::TypePath {
430433
qself: None,
@@ -462,10 +465,13 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
462465

463466
ast::ImportFunctionKind::Method { class, ty, kind }
464467
} else if opts.constructor().is_some() {
465-
let class = match js_ret {
468+
let mut class = match js_ret {
466469
Some(ref ty) => ty,
467470
_ => bail_span!(self, "constructor returns must be bare types"),
468471
};
472+
if let syn::Type::Group(syn::TypeGroup { elem, .. }) = class {
473+
class = elem;
474+
}
469475
let class_name = match *class {
470476
syn::Type::Path(syn::TypePath {
471477
qself: None,

0 commit comments

Comments
 (0)