Skip to content

Commit 77e4ecd

Browse files
committed
---
yaml --- r: 152917 b: refs/heads/try2 c: 351a5fd h: refs/heads/master i: 152915: 0492d04 v: v3
1 parent 48fcc86 commit 77e4ecd

File tree

3 files changed

+49
-6
lines changed

3 files changed

+49
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e100d26d1d779b4759f3f754b03a35755cb89b84
8+
refs/heads/try2: 351a5fd2b40c2be90f94fe2580903e93353b95ee
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/ext/expand.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub fn expand_expr(e: Gc<ast::Expr>, fld: &mut MacroExpander) -> Gc<ast::Expr> {
5454
}
5555
let extname = pth.segments.get(0).identifier;
5656
let extnamestr = token::get_ident(extname);
57-
// leaving explicit deref here to highlight unbox op:
5857
let marked_after = match fld.extsbox.find(&extname.name) {
5958
None => {
6059
fld.cx.span_err(
@@ -1294,6 +1293,19 @@ mod test {
12941293
0)
12951294
}
12961295

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+
12971309
// create a really evil test case where a $x appears inside a binding of $x
12981310
// but *shouldnt* bind because it was inserted by a different macro....
12991311
// can't write this test case until we have macro-generating macros.
@@ -1343,9 +1355,13 @@ mod test {
13431355
.ctxt,
13441356
invalid_name);
13451357
if !(varref_name==binding_name) {
1358+
let varref_idents : Vec<ast::Ident>
1359+
= varref.segments.iter().map(|s|
1360+
s.identifier)
1361+
.collect();
13461362
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));
13491365
mtwt::with_sctable(|x| mtwt::display_sctable(x));
13501366
}
13511367
assert_eq!(varref_name,binding_name);
@@ -1360,19 +1376,23 @@ mod test {
13601376
== binding_name);
13611377
// temp debugging:
13621378
if fail {
1379+
let varref_idents : Vec<ast::Ident>
1380+
= varref.segments.iter().map(|s|
1381+
s.identifier)
1382+
.collect();
13631383
println!("failure on test {}",test_idx);
13641384
println!("text of test case: \"{}\"", teststr);
13651385
println!("");
13661386
println!("uh oh, matches but shouldn't:");
1367-
println!("varref: {:?}",varref);
1387+
println!("varref: {}",varref_idents);
13681388
// good lord, you can't make a path with 0 segments, can you?
13691389
let string = token::get_ident(varref.segments
13701390
.get(0)
13711391
.identifier);
13721392
println!("varref's first segment's uint: {}, and string: \"{}\"",
13731393
varref.segments.get(0).identifier.name,
13741394
string.get());
1375-
println!("binding: {:?}", *bindings.get(binding_idx));
1395+
println!("binding: {}", *bindings.get(binding_idx));
13761396
mtwt::with_sctable(|x| mtwt::display_sctable(x));
13771397
}
13781398
assert!(!fail);
@@ -1442,5 +1462,6 @@ foo_module!()
14421462
assert_eq!(idents, strs_to_idents(vec!("a","b","None","i","i","z","y")));
14431463
}
14441464

1465+
//
14451466

14461467
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(macro_rules)]
12+
13+
macro_rules! inner_bind (
14+
( $p:pat, $id:ident) => ({let $p = 13; $id}))
15+
16+
macro_rules! outer_bind (
17+
($p:pat, $id:ident ) => (inner_bind!($p, $id)))
18+
19+
fn main() {
20+
outer_bind!(g1,g1);
21+
}
22+

0 commit comments

Comments
 (0)