@@ -167,14 +167,14 @@ pub fn parse_args(
167
167
/// so `return` statements might behave unexpectedly in this case. (this only affects direct use
168
168
/// of `py_argparse!`; `py_fn!` is unaffected as the body there is always in a separate function
169
169
/// from the generated argument-parsing code).
170
- #[ macro_export( local_inner_macros ) ]
170
+ #[ macro_export]
171
171
macro_rules! py_argparse {
172
172
( $py: expr, $fname: expr, $args: expr, $kwargs: expr, $plist: tt $body: block) => {
173
- py_argparse_parse_plist! { py_argparse_impl { $py, $fname, $args, $kwargs, $body, } $plist }
173
+ $crate :: py_argparse_parse_plist! { py_argparse_impl { $py, $fname, $args, $kwargs, $body, } $plist }
174
174
} ;
175
175
}
176
176
177
- #[ macro_export( local_inner_macros ) ]
177
+ #[ macro_export]
178
178
#[ doc( hidden) ]
179
179
macro_rules! py_argparse_parse_plist {
180
180
// Parses a parameter-list into a format more suitable for consumption by Rust macros.
@@ -184,30 +184,30 @@ macro_rules! py_argparse_parse_plist {
184
184
185
185
// Special-case entry-point for empty parameter list:
186
186
{ $callback: ident { $( $initial_arg: tt) * } ( ) } => {
187
- $callback! { $( $initial_arg) * [ ] }
187
+ $crate :: $ callback! { $( $initial_arg) * [ ] }
188
188
} ;
189
189
// Regular entry point for non-empty parameter list:
190
190
{ $callback: ident $initial_args: tt ( $( $p: tt ) + ) } => {
191
191
// add trailing comma to plist so that the parsing step can assume every
192
192
// parameter ends with a comma.
193
- py_argparse_parse_plist_impl! { $callback $initial_args [ ] ( $( $p) * , ) }
193
+ $crate :: py_argparse_parse_plist_impl! { $callback $initial_args [ ] ( $( $p) * , ) }
194
194
} ;
195
195
}
196
196
197
- #[ macro_export( local_inner_macros ) ]
197
+ #[ macro_export]
198
198
#[ doc( hidden) ]
199
199
macro_rules! py_argparse_parse_plist_impl {
200
200
// TT muncher macro that does the main work for py_argparse_parse_plist!.
201
201
202
202
// Base case: all parameters handled
203
203
{ $callback: ident { $( $initial_arg: tt) * } $output: tt ( ) } => {
204
- $callback! { $( $initial_arg) * $output }
204
+ $crate :: $ callback! { $( $initial_arg) * $output }
205
205
} ;
206
206
// Kwargs parameter with reference extraction
207
207
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
208
208
( * * $name: ident : & $t: ty , $( $tail: tt) * )
209
209
} => {
210
- py_argparse_parse_plist_impl! {
210
+ $crate :: py_argparse_parse_plist_impl! {
211
211
$callback $initial_args
212
212
[ $( $output) * { $name: & $t = [ { * * } { } { $t} ] } ]
213
213
( $( $tail) * )
@@ -217,7 +217,7 @@ macro_rules! py_argparse_parse_plist_impl {
217
217
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
218
218
( * * $name: ident : $t: ty , $( $tail: tt) * )
219
219
} => {
220
- py_argparse_parse_plist_impl! {
220
+ $crate :: py_argparse_parse_plist_impl! {
221
221
$callback $initial_args
222
222
[ $( $output) * { $name: $t = [ { * * } { } { } ] } ]
223
223
( $( $tail) * )
@@ -227,7 +227,7 @@ macro_rules! py_argparse_parse_plist_impl {
227
227
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
228
228
( * * $name: ident , $( $tail: tt) * )
229
229
} => {
230
- py_argparse_parse_plist_impl! {
230
+ $crate :: py_argparse_parse_plist_impl! {
231
231
$callback $initial_args
232
232
[ $( $output) * { $name: Option <& $crate:: PyDict > = [ { * * } { } { } ] } ]
233
233
( $( $tail) * )
@@ -237,7 +237,7 @@ macro_rules! py_argparse_parse_plist_impl {
237
237
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
238
238
( * $name: ident : & $t: ty , $( $tail: tt) * )
239
239
} => {
240
- py_argparse_parse_plist_impl! {
240
+ $crate :: py_argparse_parse_plist_impl! {
241
241
$callback $initial_args
242
242
[ $( $output) * { $name: & $t = [ { * } { } { $t} ] } ]
243
243
( $( $tail) * )
@@ -247,7 +247,7 @@ macro_rules! py_argparse_parse_plist_impl {
247
247
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
248
248
( * $name: ident : $t: ty , $( $tail: tt) * )
249
249
} => {
250
- py_argparse_parse_plist_impl! {
250
+ $crate :: py_argparse_parse_plist_impl! {
251
251
$callback $initial_args
252
252
[ $( $output) * { $name: $t = [ { * } { } { } ] } ]
253
253
( $( $tail) * )
@@ -257,7 +257,7 @@ macro_rules! py_argparse_parse_plist_impl {
257
257
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
258
258
( * $name: ident , $( $tail: tt) * )
259
259
} => {
260
- py_argparse_parse_plist_impl! {
260
+ $crate :: py_argparse_parse_plist_impl! {
261
261
$callback $initial_args
262
262
[ $( $output) * { $name: & $crate:: PyTuple = [ { * } { } { } ] } ]
263
263
( $( $tail) * )
@@ -267,7 +267,7 @@ macro_rules! py_argparse_parse_plist_impl {
267
267
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
268
268
( $name: ident : & $t: ty , $( $tail: tt) * )
269
269
} => {
270
- py_argparse_parse_plist_impl! {
270
+ $crate :: py_argparse_parse_plist_impl! {
271
271
$callback $initial_args
272
272
[ $( $output) * { $name: & $t = [ { } { } { $t} ] } ]
273
273
( $( $tail) * )
@@ -277,7 +277,7 @@ macro_rules! py_argparse_parse_plist_impl {
277
277
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
278
278
( $name: ident : $t: ty , $( $tail: tt) * )
279
279
} => {
280
- py_argparse_parse_plist_impl! {
280
+ $crate :: py_argparse_parse_plist_impl! {
281
281
$callback $initial_args
282
282
[ $( $output) * { $name: $t = [ { } { } { } ] } ]
283
283
( $( $tail) * )
@@ -287,7 +287,7 @@ macro_rules! py_argparse_parse_plist_impl {
287
287
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
288
288
( $name: ident , $( $tail: tt) * )
289
289
} => {
290
- py_argparse_parse_plist_impl! {
290
+ $crate :: py_argparse_parse_plist_impl! {
291
291
$callback $initial_args
292
292
[ $( $output) * { $name: & $crate:: PyObject = [ { } { } { } ] } ]
293
293
( $( $tail) * )
@@ -297,7 +297,7 @@ macro_rules! py_argparse_parse_plist_impl {
297
297
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
298
298
( $name: ident : & $t: ty = $default: expr, $( $tail: tt) * )
299
299
} => {
300
- py_argparse_parse_plist_impl! {
300
+ $crate :: py_argparse_parse_plist_impl! {
301
301
$callback $initial_args
302
302
[ $( $output) * { $name: & $t = [ { } { $default} { $t} ] } ]
303
303
( $( $tail) * )
@@ -307,7 +307,7 @@ macro_rules! py_argparse_parse_plist_impl {
307
307
{ $callback: ident $initial_args: tt [ $( $output: tt) * ]
308
308
( $name: ident : $t: ty = $default: expr , $( $tail: tt) * )
309
309
} => {
310
- py_argparse_parse_plist_impl! {
310
+ $crate :: py_argparse_parse_plist_impl! {
311
311
$callback $initial_args
312
312
[ $( $output) * { $name: $t = [ { } { $default} { } ] } ]
313
313
( $( $tail) * )
@@ -317,7 +317,7 @@ macro_rules! py_argparse_parse_plist_impl {
317
317
318
318
// The main py_argparse!() macro, except that it expects the parameter-list
319
319
// in the output format of py_argparse_parse_plist!().
320
- #[ macro_export( local_inner_macros ) ]
320
+ #[ macro_export]
321
321
#[ doc( hidden) ]
322
322
macro_rules! py_argparse_impl {
323
323
// special case: function signature is (*args, **kwargs),
@@ -341,11 +341,11 @@ macro_rules! py_argparse_impl {
341
341
) => { {
342
342
const PARAMS : & ' static [ $crate:: argparse:: ParamDescription <' static >] = & [
343
343
$(
344
- py_argparse_param_description! { $pname : $ptype = $detail }
344
+ $crate :: py_argparse_param_description! { $pname : $ptype = $detail }
345
345
) ,*
346
346
] ;
347
347
let py: $crate:: Python = $py;
348
- let mut output = [ $( py_replace_expr!( $pname None ) ) ,* ] ;
348
+ let mut output = [ $( $crate :: py_replace_expr!( $pname None ) ) ,* ] ;
349
349
match $crate:: argparse:: parse_args( py, $fname, PARAMS , $args, $kwargs, & mut output) {
350
350
Ok ( ( ) ) => {
351
351
// Experimental slice pattern syntax would be really nice here (#23121)
@@ -355,7 +355,7 @@ macro_rules! py_argparse_impl {
355
355
// We'll have to generate a bunch of nested `match` statements
356
356
// (at least until we can use ? + catch, assuming that will be hygienic wrt. macros),
357
357
// so use a recursive helper macro for that:
358
- py_argparse_extract!( py, _iter, $body,
358
+ $crate :: py_argparse_extract!( py, _iter, $body,
359
359
[ $( { $pname : $ptype = $detail } ) * ] )
360
360
} ,
361
361
Err ( e) => Err ( e)
@@ -364,14 +364,14 @@ macro_rules! py_argparse_impl {
364
364
}
365
365
366
366
// Like py_argparse_impl!(), but accepts `*mut ffi::PyObject` for $args and $kwargs.
367
- #[ macro_export( local_inner_macros ) ]
367
+ #[ macro_export]
368
368
#[ doc( hidden) ]
369
369
macro_rules! py_argparse_raw {
370
370
( $py: ident, $fname: expr, $args: expr, $kwargs: expr, $plist: tt $body: block) => { {
371
371
let args: $crate:: PyTuple =
372
372
$crate:: PyObject :: from_borrowed_ptr( $py, $args) . unchecked_cast_into( ) ;
373
373
let kwargs: Option <$crate:: PyDict > = $crate:: argparse:: get_kwargs( $py, $kwargs) ;
374
- let ret = py_argparse_impl!( $py, $fname, & args, kwargs. as_ref( ) , $body, $plist) ;
374
+ let ret = $crate :: py_argparse_impl!( $py, $fname, & args, kwargs. as_ref( ) , $body, $plist) ;
375
375
$crate:: PyDrop :: release_ref( args, $py) ;
376
376
$crate:: PyDrop :: release_ref( kwargs, $py) ;
377
377
ret
@@ -407,7 +407,7 @@ macro_rules! py_argparse_param_description {
407
407
) ;
408
408
}
409
409
410
- #[ macro_export( local_inner_macros ) ]
410
+ #[ macro_export]
411
411
#[ doc( hidden) ]
412
412
macro_rules! py_argparse_extract {
413
413
// base case
@@ -419,7 +419,7 @@ macro_rules! py_argparse_extract {
419
419
// First unwrap() asserts the iterated sequence is long enough (which should be guaranteed);
420
420
// second unwrap() asserts the parameter was not missing (which fn parse_args already checked for).
421
421
match <$ptype as $crate:: FromPyObject >:: extract( $py, $iter. next( ) . unwrap( ) . as_ref( ) . unwrap( ) ) {
422
- Ok ( $pname) => py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] ) ,
422
+ Ok ( $pname) => $crate :: py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] ) ,
423
423
Err ( e) => Err ( e)
424
424
}
425
425
} ;
@@ -431,7 +431,7 @@ macro_rules! py_argparse_extract {
431
431
// second unwrap() asserts the parameter was not missing (which fn parse_args already checked for).
432
432
match <$rtype as $crate:: RefFromPyObject >:: with_extracted( $py,
433
433
$iter. next( ) . unwrap( ) . as_ref( ) . unwrap( ) ,
434
- |$pname: $ptype| py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] )
434
+ |$pname: $ptype| $crate :: py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] )
435
435
) {
436
436
Ok ( v) => v,
437
437
Err ( e) => Err ( e)
@@ -442,7 +442,7 @@ macro_rules! py_argparse_extract {
442
442
[ { $pname: ident : $ptype: ty = [ { } { $default: expr} { } ] } $( $tail: tt) * ]
443
443
) => {
444
444
match $iter. next( ) . unwrap( ) . as_ref( ) . map( |obj| obj. extract:: <_>( $py) ) . unwrap_or( Ok ( $default) ) {
445
- Ok ( $pname) => py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] ) ,
445
+ Ok ( $pname) => $crate :: py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] ) ,
446
446
Err ( e) => Err ( e)
447
447
}
448
448
} ;
@@ -453,7 +453,7 @@ macro_rules! py_argparse_extract {
453
453
//unwrap() asserts the iterated sequence is long enough (which should be guaranteed);
454
454
$crate:: argparse:: with_extracted_or_default( $py,
455
455
$iter. next( ) . unwrap( ) . as_ref( ) ,
456
- |$pname: $ptype| py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] ) ,
456
+ |$pname: $ptype| $crate :: py_argparse_extract!( $py, $iter, $body, [ $( $tail) * ] ) ,
457
457
$default)
458
458
} ;
459
459
}
0 commit comments