Skip to content

Commit 9ffd1dc

Browse files
author
Jorge Aparicio
committed
---
yaml --- r: 170463 b: refs/heads/try c: 70ce68e h: refs/heads/master i: 170461: cd5204a 170459: b4f74b5 170455: 5e4a806 170447: f470b87 170431: cebd457 v: v3
1 parent d881bfe commit 9ffd1dc

File tree

5 files changed

+36
-32
lines changed

5 files changed

+36
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 73a25f55ad748b4d3516417c711b99ce446591af
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 5b3cd3900ceda838f5798c30ab96ceb41f962534
5-
refs/heads/try: 371f04d4330f70cfab5fa2a5fdb65df7ccd0604c
5+
refs/heads/try: 70ce68eed4f81ff90cf3710e3fdb7b04de71a388
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/libsyntax/ast_util.rs

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -618,34 +618,38 @@ pub fn compute_id_range_for_fn_body(fk: visit::FnKind,
618618
id_visitor.operation.result
619619
}
620620

621-
// FIXME(#19596) unbox `it`
622-
pub fn walk_pat(pat: &Pat, it: |&Pat| -> bool) -> bool {
623-
if !it(pat) {
624-
return false;
625-
}
626-
627-
match pat.node {
628-
PatIdent(_, _, Some(ref p)) => walk_pat(&**p, it),
629-
PatStruct(_, ref fields, _) => {
630-
fields.iter().all(|field| walk_pat(&*field.node.pat, |p| it(p)))
631-
}
632-
PatEnum(_, Some(ref s)) | PatTup(ref s) => {
633-
s.iter().all(|p| walk_pat(&**p, |p| it(p)))
621+
pub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool where F: FnMut(&Pat) -> bool {
622+
// FIXME(#19596) this is a workaround, but there should be a better way
623+
fn walk_pat_<G>(pat: &Pat, it: &mut G) -> bool where G: FnMut(&Pat) -> bool {
624+
if !(*it)(pat) {
625+
return false;
634626
}
635-
PatBox(ref s) | PatRegion(ref s) => {
636-
walk_pat(&**s, it)
637-
}
638-
PatVec(ref before, ref slice, ref after) => {
639-
before.iter().all(|p| walk_pat(&**p, |p| it(p))) &&
640-
slice.iter().all(|p| walk_pat(&**p, |p| it(p))) &&
641-
after.iter().all(|p| walk_pat(&**p, |p| it(p)))
642-
}
643-
PatMac(_) => panic!("attempted to analyze unexpanded pattern"),
644-
PatWild(_) | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |
645-
PatEnum(_, _) => {
646-
true
627+
628+
match pat.node {
629+
PatIdent(_, _, Some(ref p)) => walk_pat_(&**p, it),
630+
PatStruct(_, ref fields, _) => {
631+
fields.iter().all(|field| walk_pat_(&*field.node.pat, it))
632+
}
633+
PatEnum(_, Some(ref s)) | PatTup(ref s) => {
634+
s.iter().all(|p| walk_pat_(&**p, it))
635+
}
636+
PatBox(ref s) | PatRegion(ref s) => {
637+
walk_pat_(&**s, it)
638+
}
639+
PatVec(ref before, ref slice, ref after) => {
640+
before.iter().all(|p| walk_pat_(&**p, it)) &&
641+
slice.iter().all(|p| walk_pat_(&**p, it)) &&
642+
after.iter().all(|p| walk_pat_(&**p, it))
643+
}
644+
PatMac(_) => panic!("attempted to analyze unexpanded pattern"),
645+
PatWild(_) | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) |
646+
PatEnum(_, _) => {
647+
true
648+
}
647649
}
648650
}
651+
652+
walk_pat_(pat, &mut it)
649653
}
650654

651655
pub trait EachViewItem {

branches/try/src/libsyntax/ext/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ pub trait ItemDecorator {
4747
sp: Span,
4848
meta_item: &ast::MetaItem,
4949
item: &ast::Item,
50-
push: |P<ast::Item>|);
50+
push: Box<FnMut(P<ast::Item>)>);
5151
}
5252

5353
impl<F> ItemDecorator for F
54-
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, |P<ast::Item>|)
54+
where F : Fn(&mut ExtCtxt, Span, &ast::MetaItem, &ast::Item, Box<FnMut(P<ast::Item>)>)
5555
{
5656
fn expand(&self,
5757
ecx: &mut ExtCtxt,
5858
sp: Span,
5959
meta_item: &ast::MetaItem,
6060
item: &ast::Item,
61-
push: |P<ast::Item>|) {
61+
push: Box<FnMut(P<ast::Item>)>) {
6262
(*self)(ecx, sp, meta_item, item, push)
6363
}
6464
}

branches/try/src/libsyntax/ext/deriving/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
4545
_span: Span,
4646
mitem: &MetaItem,
4747
item: &Item,
48-
push: |P<Item>|) {
48+
mut push: Box<FnMut(P<Item>)>) {
4949
match mitem.node {
5050
MetaNameValue(_, ref l) => {
5151
cx.span_err(l.span, "unexpected value in `deriving`");
@@ -64,7 +64,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
6464
MetaWord(ref tname) => {
6565
macro_rules! expand(($func:path) => ($func(cx, titem.span,
6666
&**titem, item,
67-
|i| push(i))));
67+
|i| push.call_mut((i,)))));
6868
match tname.get() {
6969
"Clone" => expand!(clone::expand_deriving_clone),
7070

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander)
424424
// but that double-mut-borrows fld
425425
let mut items: SmallVector<P<ast::Item>> = SmallVector::zero();
426426
dec.expand(fld.cx, attr.span, &*attr.node.value, &*it,
427-
|item| items.push(item));
427+
box |&mut : item| items.push(item));
428428
decorator_items.extend(items.into_iter()
429429
.flat_map(|item| expand_item(item, fld).into_iter()));
430430

0 commit comments

Comments
 (0)