@@ -54,7 +54,6 @@ pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
54
54
}
55
55
let extname = pth. segments . get ( 0 ) . identifier ;
56
56
let extnamestr = token:: get_ident ( extname) ;
57
- // leaving explicit deref here to highlight unbox op:
58
57
let marked_after = match fld. extsbox . find ( & extname. name ) {
59
58
None => {
60
59
fld. cx . span_err (
@@ -1294,6 +1293,19 @@ mod test {
1294
1293
0 )
1295
1294
}
1296
1295
1296
+ // FIXME #15221, somehow pats aren't getting labeled correctly?
1297
+ // should expand into
1298
+ // fn main(){let g1_1 = 13; g1_1}}
1299
+ #[ test] fn pat_expand_issue_15221 ( ) {
1300
+ run_renaming_test (
1301
+ & ( "macro_rules! inner ( ($e:pat ) => ($e))
1302
+ macro_rules! outer ( ($e:pat ) => (inner!($e)))
1303
+ fn main() { let outer!(g) = 13; g;}" ,
1304
+ vec ! ( vec!( 0 ) ) ,
1305
+ true ) ,
1306
+ 0 )
1307
+ }
1308
+
1297
1309
// create a really evil test case where a $x appears inside a binding of $x
1298
1310
// but *shouldnt* bind because it was inserted by a different macro....
1299
1311
// can't write this test case until we have macro-generating macros.
@@ -1343,9 +1355,13 @@ mod test {
1343
1355
. ctxt ,
1344
1356
invalid_name) ;
1345
1357
if !( varref_name==binding_name) {
1358
+ let varref_idents : Vec < ast:: Ident >
1359
+ = varref. segments . iter ( ) . map ( |s|
1360
+ s. identifier )
1361
+ . collect ( ) ;
1346
1362
println ! ( "uh oh, should match but doesn't:" ) ;
1347
- println ! ( "varref #{:? }: {:? }" , idx, varref ) ;
1348
- println ! ( "binding #{:? }: {:? }" , binding_idx, * bindings. get( binding_idx) ) ;
1363
+ println ! ( "varref #{}: {}" , idx, varref_idents ) ;
1364
+ println ! ( "binding #{}: {}" , binding_idx, * bindings. get( binding_idx) ) ;
1349
1365
mtwt:: with_sctable ( |x| mtwt:: display_sctable ( x) ) ;
1350
1366
}
1351
1367
assert_eq ! ( varref_name, binding_name) ;
@@ -1360,19 +1376,23 @@ mod test {
1360
1376
== binding_name) ;
1361
1377
// temp debugging:
1362
1378
if fail {
1379
+ let varref_idents : Vec < ast:: Ident >
1380
+ = varref. segments . iter ( ) . map ( |s|
1381
+ s. identifier )
1382
+ . collect ( ) ;
1363
1383
println ! ( "failure on test {}" , test_idx) ;
1364
1384
println ! ( "text of test case: \" {}\" " , teststr) ;
1365
1385
println ! ( "" ) ;
1366
1386
println ! ( "uh oh, matches but shouldn't:" ) ;
1367
- println ! ( "varref: {:? }" , varref ) ;
1387
+ println ! ( "varref: {}" , varref_idents ) ;
1368
1388
// good lord, you can't make a path with 0 segments, can you?
1369
1389
let string = token:: get_ident ( varref. segments
1370
1390
. get ( 0 )
1371
1391
. identifier ) ;
1372
1392
println ! ( "varref's first segment's uint: {}, and string: \" {}\" " ,
1373
1393
varref. segments. get( 0 ) . identifier. name,
1374
1394
string. get( ) ) ;
1375
- println ! ( "binding: {:? }" , * bindings. get( binding_idx) ) ;
1395
+ println ! ( "binding: {}" , * bindings. get( binding_idx) ) ;
1376
1396
mtwt:: with_sctable ( |x| mtwt:: display_sctable ( x) ) ;
1377
1397
}
1378
1398
assert ! ( !fail) ;
@@ -1442,5 +1462,6 @@ foo_module!()
1442
1462
assert_eq ! ( idents, strs_to_idents( vec!( "a" , "b" , "None" , "i" , "i" , "z" , "y" ) ) ) ;
1443
1463
}
1444
1464
1465
+ //
1445
1466
1446
1467
}
0 commit comments