@@ -863,7 +863,7 @@ impl<'a> MacroParse<BindgenAttrs> for &'a mut syn::ItemImpl {
863
863
syn:: Type :: Path ( syn:: TypePath {
864
864
qself : None ,
865
865
ref path,
866
- } ) => extract_path_ident ( path) ? ,
866
+ } ) => path,
867
867
_ => bail_span ! (
868
868
self . self_ty,
869
869
"unsupported self type in #[wasm_bindgen] impl"
@@ -891,7 +891,7 @@ impl<'a> MacroParse<BindgenAttrs> for &'a mut syn::ItemImpl {
891
891
// then go for the rest.
892
892
fn prepare_for_impl_recursion (
893
893
item : & mut syn:: ImplItem ,
894
- class : & Ident ,
894
+ class : & syn :: Path ,
895
895
impl_opts : & BindgenAttrs ,
896
896
) -> Result < ( ) , Diagnostic > {
897
897
let method = match item {
@@ -917,10 +917,12 @@ fn prepare_for_impl_recursion(
917
917
other => bail_span ! ( other, "failed to parse this item as a known item" ) ,
918
918
} ;
919
919
920
+ let ident = extract_path_ident ( class) ?;
921
+
920
922
let js_class = impl_opts
921
923
. js_class ( )
922
924
. map ( |s| s. 0 . to_string ( ) )
923
- . unwrap_or ( class . to_string ( ) ) ;
925
+ . unwrap_or ( ident . to_string ( ) ) ;
924
926
925
927
method. attrs . insert (
926
928
0 ,
@@ -1291,20 +1293,23 @@ fn assert_not_variadic(attrs: &BindgenAttrs) -> Result<(), Diagnostic> {
1291
1293
Ok ( ( ) )
1292
1294
}
1293
1295
1294
- /// If the path is a single ident, return it.
1296
+ /// Extracts the last ident from the path
1295
1297
fn extract_path_ident ( path : & syn:: Path ) -> Result < Ident , Diagnostic > {
1296
- if path. leading_colon . is_some ( ) {
1297
- bail_span ! ( path , "global paths are not supported yet" ) ;
1298
- }
1299
- if path . segments . len ( ) != 1 {
1300
- bail_span ! ( path , "multi-segment paths are not supported yet" ) ;
1298
+ for segment in path. segments . iter ( ) {
1299
+ match segment . arguments {
1300
+ syn :: PathArguments :: None => { }
1301
+ _ => bail_span ! ( path , "paths with type parameters are not supported yet" ) ,
1302
+ }
1301
1303
}
1302
- let value = & path. segments [ 0 ] ;
1303
- match value. arguments {
1304
- syn:: PathArguments :: None => { }
1305
- _ => bail_span ! ( path, "paths with type parameters are not supported yet" ) ,
1304
+
1305
+ match path. segments . last ( ) {
1306
+ Some ( value) => {
1307
+ Ok ( value. ident . clone ( ) )
1308
+ } ,
1309
+ None => {
1310
+ bail_span ! ( path, "empty idents are not supported" ) ;
1311
+ } ,
1306
1312
}
1307
- Ok ( value. ident . clone ( ) )
1308
1313
}
1309
1314
1310
1315
pub fn reset_attrs_used ( ) {
0 commit comments