File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -169,13 +169,11 @@ where
169
169
while let Some ( ( _, attr) ) = iter. peek ( ) {
170
170
// take all cfgs but no py items
171
171
let attr = * attr;
172
- if let Some ( ident) = attr. get_ident ( ) {
173
- let attr_name = ident. to_string ( ) ;
174
- if attr_name == "cfg" {
175
- cfgs. push ( attr. clone ( ) ) ;
176
- } else if ALL_ALLOWED_NAMES . contains ( & attr_name. as_str ( ) ) {
177
- break ;
178
- }
172
+ let attr_path = attr. path_string ( ) ;
173
+ if attr_path == "cfg" {
174
+ cfgs. push ( attr. clone ( ) ) ;
175
+ } else if attr_path. starts_with ( "py" ) {
176
+ break ;
179
177
}
180
178
iter. next ( ) ;
181
179
}
@@ -184,7 +182,7 @@ where
184
182
let mut pyattrs = Vec :: new ( ) ;
185
183
for ( i, attr) in iter {
186
184
// take py items but no cfgs
187
- let attr_name = attr. path . to_string ( ) ;
185
+ let attr_name = attr. path_string ( ) ;
188
186
if attr_name == "cfg" {
189
187
return Err ( syn:: Error :: new_spanned (
190
188
attr,
Original file line number Diff line number Diff line change @@ -380,7 +380,15 @@ impl AttributeExt for Attribute {
380
380
Ok ( list. nested )
381
381
}
382
382
fn ident_and_promoted_nested ( & self ) -> Result < ( & Ident , PunctuatedNestedMeta ) > {
383
- Ok ( ( self . get_ident ( ) . unwrap ( ) , self . promoted_nested ( ) ?) )
383
+ let ident = self . get_ident ( ) . unwrap_or_else ( || {
384
+ & self
385
+ . path
386
+ . segments
387
+ . last ( )
388
+ . expect ( "py:: paths always have segment" )
389
+ . ident
390
+ } ) ;
391
+ Ok ( ( ident, self . promoted_nested ( ) ?) )
384
392
}
385
393
386
394
fn try_remove_name ( & mut self , item_name : & str ) -> Result < Option < syn:: NestedMeta > > {
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ mod builtins {
37
37
} ;
38
38
use num_traits:: { Signed , ToPrimitive , Zero } ;
39
39
40
- #[ pyfunction ]
40
+ #[ py :: function ]
41
41
fn abs ( x : PyObjectRef , vm : & VirtualMachine ) -> PyResult {
42
42
vm. _abs ( & x)
43
43
}
You can’t perform that action at this time.
0 commit comments