File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -184,17 +184,14 @@ where
184
184
let mut pyattrs = Vec :: new ( ) ;
185
185
for ( i, attr) in iter {
186
186
// take py items but no cfgs
187
- let attr_name = if let Some ( ident) = attr. get_ident ( ) {
188
- ident. to_string ( )
189
- } else {
190
- continue ;
191
- } ;
187
+ let attr_name = attr. path . to_string ( ) ;
192
188
if attr_name == "cfg" {
193
189
return Err ( syn:: Error :: new_spanned (
194
190
attr,
195
191
"#[py*] items must be placed under `cfgs`" ,
196
192
) ) ;
197
193
}
194
+ let attr_name = attr_name. replace ( "::" , "" ) ;
198
195
199
196
let attr_name = match AttrName :: from_str ( attr_name. as_str ( ) ) {
200
197
Ok ( name) => name,
Original file line number Diff line number Diff line change @@ -25,6 +25,11 @@ pub(crate) const ALL_ALLOWED_NAMES: &[&str] = &[
25
25
"extend_class" ,
26
26
] ;
27
27
28
+ pub fn path_to_string ( path : & syn:: Path ) -> String {
29
+ let x = format ! ( "{}" , quote! { #path} ) ;
30
+ x. replace ( ' ' , "" )
31
+ }
32
+
28
33
#[ derive( Default ) ]
29
34
pub ( crate ) struct ItemNursery ( IndexMap < ( String , Vec < Attribute > ) , TokenStream > ) ;
30
35
@@ -346,6 +351,7 @@ pub(crate) fn path_eq(path: &Path, s: &str) -> bool {
346
351
}
347
352
348
353
pub ( crate ) trait AttributeExt : SynAttributeExt {
354
+ fn path_string ( & self ) -> String ;
349
355
fn promoted_nested ( & self ) -> Result < PunctuatedNestedMeta > ;
350
356
fn ident_and_promoted_nested ( & self ) -> Result < ( & Ident , PunctuatedNestedMeta ) > ;
351
357
fn try_remove_name ( & mut self , name : & str ) -> Result < Option < syn:: NestedMeta > > ;
@@ -355,9 +361,12 @@ pub(crate) trait AttributeExt: SynAttributeExt {
355
361
}
356
362
357
363
impl AttributeExt for Attribute {
364
+ fn path_string ( & self ) -> String {
365
+ path_to_string ( & self . path )
366
+ }
358
367
fn promoted_nested ( & self ) -> Result < PunctuatedNestedMeta > {
359
368
let list = self . promoted_list ( ) . map_err ( |mut e| {
360
- let name = self . get_ident ( ) . unwrap ( ) . to_string ( ) ;
369
+ let name = self . path_string ( ) ;
361
370
e. combine ( syn:: Error :: new_spanned (
362
371
self ,
363
372
format ! (
You can’t perform that action at this time.
0 commit comments