@@ -376,6 +376,14 @@ impl<'a> ConvertToAst<BindgenAttrs> for &'a mut syn::ItemStruct {
376
376
}
377
377
}
378
378
379
+ fn get_ty ( mut ty : & syn:: Type ) -> & syn:: Type {
380
+ while let syn:: Type :: Group ( g) = ty {
381
+ ty = & g. elem ;
382
+ }
383
+
384
+ ty
385
+ }
386
+
379
387
impl < ' a > ConvertToAst < ( BindgenAttrs , & ' a ast:: ImportModule ) > for syn:: ForeignItemFn {
380
388
type Target = ast:: ImportKind ;
381
389
@@ -414,7 +422,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
414
422
let class = wasm. arguments . get ( 0 ) . ok_or_else ( || {
415
423
err_span ! ( self , "imported methods must have at least one argument" )
416
424
} ) ?;
417
- let class = match & * class. ty {
425
+ let class = match get_ty ( & class. ty ) {
418
426
syn:: Type :: Reference ( syn:: TypeReference {
419
427
mutability : None ,
420
428
elem,
@@ -425,7 +433,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
425
433
"first argument of method must be a shared reference"
426
434
) ,
427
435
} ;
428
- let class_name = match * class {
436
+ let class_name = match get_ty ( class) {
429
437
syn:: Type :: Path ( syn:: TypePath {
430
438
qself : None ,
431
439
ref path,
@@ -466,7 +474,7 @@ impl<'a> ConvertToAst<(BindgenAttrs, &'a ast::ImportModule)> for syn::ForeignIte
466
474
Some ( ref ty) => ty,
467
475
_ => bail_span ! ( self , "constructor returns must be bare types" ) ,
468
476
} ;
469
- let class_name = match * class {
477
+ let class_name = match get_ty ( class) {
470
478
syn:: Type :: Path ( syn:: TypePath {
471
479
qself : None ,
472
480
ref path,
@@ -666,9 +674,9 @@ fn function_from_decl(
666
674
Some ( i) => i,
667
675
None => return t,
668
676
} ;
669
- let path = match t {
670
- syn:: Type :: Path ( syn:: TypePath { qself : None , path } ) => path,
671
- other => return other,
677
+ let path = match get_ty ( & t ) {
678
+ syn:: Type :: Path ( syn:: TypePath { qself : None , path } ) => path. clone ( ) ,
679
+ other => return other. clone ( ) ,
672
680
} ;
673
681
let new_path = if path. segments . len ( ) == 1 && path. segments [ 0 ] . ident == "Self" {
674
682
self_ty. clone ( ) . into ( )
@@ -869,7 +877,7 @@ impl<'a> MacroParse<BindgenAttrs> for &'a mut syn::ItemImpl {
869
877
"#[wasm_bindgen] generic impls aren't supported"
870
878
) ;
871
879
}
872
- let name = match * self . self_ty {
880
+ let name = match get_ty ( & self . self_ty ) {
873
881
syn:: Type :: Path ( syn:: TypePath {
874
882
qself : None ,
875
883
ref path,
@@ -1286,7 +1294,7 @@ fn extract_first_ty_param(ty: Option<&syn::Type>) -> Result<Option<syn::Type>, D
1286
1294
Some ( t) => t,
1287
1295
None => return Ok ( None ) ,
1288
1296
} ;
1289
- let path = match * t {
1297
+ let path = match * get_ty ( & t ) {
1290
1298
syn:: Type :: Path ( syn:: TypePath {
1291
1299
qself : None ,
1292
1300
ref path,
@@ -1309,7 +1317,7 @@ fn extract_first_ty_param(ty: Option<&syn::Type>) -> Result<Option<syn::Type>, D
1309
1317
syn:: GenericArgument :: Type ( t) => t,
1310
1318
other => bail_span ! ( other, "must be a type parameter" ) ,
1311
1319
} ;
1312
- match ty {
1320
+ match get_ty ( & ty ) {
1313
1321
syn:: Type :: Tuple ( t) if t. elems . len ( ) == 0 => return Ok ( None ) ,
1314
1322
_ => { }
1315
1323
}
0 commit comments