Skip to content

Commit

Permalink
Handle the possibility that the class name is in its own Group
Browse files Browse the repository at this point in the history
rust-lang/rust#72388 makes this happen
  • Loading branch information
rrbutani committed May 26, 2020
1 parent 4d3cfe6 commit 56d254d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/macro-support/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
let class = wasm.arguments.get(0).ok_or_else(|| {
err_span!(self, "imported methods must have at least one argument")
})?;
let class = match &*class.ty {
let mut class = match &*class.ty {
syn::Type::Reference(syn::TypeReference {
mutability: None,
elem,
Expand All @@ -425,6 +425,9 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
"first argument of method must be a shared reference"
),
};
if let syn::Type::Group(syn::TypeGroup { elem, .. }) = class {
class = elem;
}
let class_name = match *class {
syn::Type::Path(syn::TypePath {
qself: None,
Expand Down Expand Up @@ -462,10 +465,13 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte

ast::ImportFunctionKind::Method { class, ty, kind }
} else if opts.constructor().is_some() {
let class = match js_ret {
let mut class = match js_ret {
Some(ref ty) => ty,
_ => bail_span!(self, "constructor returns must be bare types"),
};
if let syn::Type::Group(syn::TypeGroup { elem, .. }) = class {
class = elem;
}
let class_name = match *class {
syn::Type::Path(syn::TypePath {
qself: None,
Expand Down

0 comments on commit 56d254d

Please sign in to comment.