Skip to content

Commit 5f9ed05

Browse files
committed
---
yaml --- r: 12532 b: refs/heads/master c: 1da18c7 h: refs/heads/master v: v3
1 parent dd34527 commit 5f9ed05

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 030404c793cd20bf8b7eb11f91f3f0f8010bf52a
2+
refs/heads/master: 1da18c70ac96ddec31627d2454a60ce441cf29e1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/librustsyntax/fold.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type ast_fold_precursor =
4040
fold_expr: fn@(expr_, span, ast_fold) -> (expr_, span),
4141
fold_ty: fn@(ty_, span, ast_fold) -> (ty_, span),
4242
fold_constr: fn@(ast::constr_, span, ast_fold) -> (constr_, span),
43+
fold_ty_constr: fn@(ast::ty_constr_, span, ast_fold)
44+
-> (ty_constr_, span),
4345
fold_mod: fn@(_mod, ast_fold) -> _mod,
4446
fold_native_mod: fn@(native_mod, ast_fold) -> native_mod,
4547
fold_variant: fn@(variant_, span, ast_fold) -> (variant_, span),
@@ -67,6 +69,7 @@ type a_f =
6769
fold_expr: fn@(&&@expr) -> @expr,
6870
fold_ty: fn@(&&@ty) -> @ty,
6971
fold_constr: fn@(&&@constr) -> @constr,
72+
fold_ty_constr: fn@(&&@ty_constr) -> @ty_constr,
7073
fold_mod: fn@(_mod) -> _mod,
7174
fold_native_mod: fn@(native_mod) -> native_mod,
7275
fold_variant: fn@(variant) -> variant,
@@ -97,6 +100,7 @@ fn nf_decl_dummy(&&_d: @decl) -> @decl { fail; }
97100
fn nf_expr_dummy(&&_e: @expr) -> @expr { fail; }
98101
fn nf_ty_dummy(&&_t: @ty) -> @ty { fail; }
99102
fn nf_constr_dummy(&&_c: @constr) -> @constr { fail; }
103+
fn nf_ty_constr_dummy(&&_c: @ty_constr) -> @ty_constr { fail; }
100104
fn nf_mod_dummy(_m: _mod) -> _mod { fail; }
101105
fn nf_native_mod_dummy(_n: native_mod) -> native_mod { fail; }
102106
fn nf_variant_dummy(_v: variant) -> variant { fail; }
@@ -141,9 +145,7 @@ fn fold_mac_(m: mac, fld: ast_fold) -> mac {
141145
alt m.node {
142146
mac_invoc(pth, arg, body) {
143147
mac_invoc(fld.fold_path(pth),
144-
// FIXME: bind should work, but causes a crash
145-
option::map(arg) {|arg| fld.fold_expr(arg)},
146-
body)
148+
option::map(arg, fld.fold_expr), body)
147149
}
148150
mac_embed_type(ty) { mac_embed_type(fld.fold_ty(ty)) }
149151
mac_embed_block(blk) { mac_embed_block(fld.fold_block(blk)) }
@@ -500,8 +502,8 @@ fn noop_fold_ty(t: ty_, fld: ast_fold) -> ty_ {
500502
ty_fn(proto, decl) {ty_fn(proto, fold_fn_decl(decl, fld))}
501503
ty_tup(tys) {ty_tup(vec::map(tys) {|ty| fld.fold_ty(ty)})}
502504
ty_path(path, id) {ty_path(fld.fold_path(path), fld.new_id(id))}
503-
// FIXME: constrs likely needs to be folded...
504-
ty_constr(ty, constrs) {ty_constr(fld.fold_ty(ty), constrs)}
505+
ty_constr(ty, constrs) {ty_constr(fld.fold_ty(ty),
506+
vec::map(constrs, fld.fold_ty_constr))}
505507
ty_vstore(t, vs) {ty_vstore(fld.fold_ty(t), vs)}
506508
ty_mac(mac) {ty_mac(fold_mac(mac))}
507509
ty_infer {t}
@@ -512,6 +514,11 @@ fn noop_fold_constr(c: constr_, fld: ast_fold) -> constr_ {
512514
{path: fld.fold_path(c.path), args: c.args, id: fld.new_id(c.id)}
513515
}
514516

517+
fn noop_fold_ty_constr(c: ty_constr_, fld: ast_fold) -> ty_constr_ {
518+
let rslt: ty_constr_ =
519+
{path: fld.fold_path(c.path), args: c.args, id: fld.new_id(c.id)};
520+
rslt
521+
}
515522
// ...nor do modules
516523
fn noop_fold_mod(m: _mod, fld: ast_fold) -> _mod {
517524
ret {view_items: vec::map(m.view_items, fld.fold_view_item),
@@ -594,6 +601,7 @@ fn default_ast_fold() -> @ast_fold_precursor {
594601
fold_expr: wrap(noop_fold_expr),
595602
fold_ty: wrap(noop_fold_ty),
596603
fold_constr: wrap(noop_fold_constr),
604+
fold_ty_constr: wrap(noop_fold_ty_constr),
597605
fold_mod: noop_fold_mod,
598606
fold_native_mod: noop_fold_native_mod,
599607
fold_variant: wrap(noop_fold_variant),
@@ -608,6 +616,7 @@ fn default_ast_fold() -> @ast_fold_precursor {
608616
fn make_fold(afp: ast_fold_precursor) -> ast_fold {
609617
// FIXME: Have to bind all the bare functions into shared functions
610618
// because @mut is invariant with respect to its contents
619+
// I assume this has something to do with Issue #1973 - tjc
611620
let result: ast_fold =
612621
@mut {fold_crate: bind nf_crate_dummy(_),
613622
fold_crate_directive: bind nf_crate_directive_dummy(_),
@@ -625,6 +634,7 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
625634
fold_expr: bind nf_expr_dummy(_),
626635
fold_ty: bind nf_ty_dummy(_),
627636
fold_constr: bind nf_constr_dummy(_),
637+
fold_ty_constr: bind nf_ty_constr_dummy(_),
628638
fold_mod: bind nf_mod_dummy(_),
629639
fold_native_mod: bind nf_native_mod_dummy(_),
630640
fold_variant: bind nf_variant_dummy(_),
@@ -714,6 +724,13 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
714724
let (n, s) = afp.fold_constr(x.node, x.span, f);
715725
ret @{node: n, span: afp.new_span(s)};
716726
}
727+
fn f_ty_constr(afp: ast_fold_precursor, f: ast_fold,
728+
&&x: @ast::ty_constr) ->
729+
@ast::ty_constr {
730+
let (n, s) : (ty_constr_, span) =
731+
afp.fold_ty_constr(x.node, x.span, f);
732+
ret @{node: n, span: afp.new_span(s)};
733+
}
717734
fn f_mod(afp: ast_fold_precursor, f: ast_fold, x: _mod) -> _mod {
718735
ret afp.fold_mod(x, f);
719736
}
@@ -755,6 +772,7 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
755772
fold_expr: bind f_expr(afp, result, _),
756773
fold_ty: bind f_ty(afp, result, _),
757774
fold_constr: bind f_constr(afp, result, _),
775+
fold_ty_constr: bind f_ty_constr(afp, result, _),
758776
fold_mod: bind f_mod(afp, result, _),
759777
fold_native_mod: bind f_native_mod(afp, result, _),
760778
fold_variant: bind f_variant(afp, result, _),

0 commit comments

Comments
 (0)