Skip to content

Commit f951b52

Browse files
committed
Add support to pat_lit to fold.
1 parent 2773348 commit f951b52

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/comp/middle/fold.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ type ast_fold[ENV] =
160160
(fn(&ENV e, &span sp,
161161
ann a) -> @pat) fold_pat_wild,
162162

163+
(fn(&ENV e, &span sp,
164+
@ast.lit lit, ann a) -> @pat) fold_pat_lit,
165+
163166
(fn(&ENV e, &span sp,
164167
ident i, def_id did, ann a) -> @pat) fold_pat_bind,
165168

@@ -421,6 +424,9 @@ fn fold_pat[ENV](&ENV env, ast_fold[ENV] fld, @ast.pat p) -> @ast.pat {
421424

422425
alt (p.node) {
423426
case (ast.pat_wild(?t)) { ret fld.fold_pat_wild(env_, p.span, t); }
427+
case (ast.pat_lit(?lt, ?t)) {
428+
ret fld.fold_pat_lit(env_, p.span, lt, t);
429+
}
424430
case (ast.pat_bind(?id, ?did, ?t)) {
425431
ret fld.fold_pat_bind(env_, p.span, id, did, t);
426432
}
@@ -1122,6 +1128,10 @@ fn identity_fold_pat_wild[ENV](&ENV e, &span sp, ann a) -> @pat {
11221128
ret @respan(sp, ast.pat_wild(a));
11231129
}
11241130

1131+
fn identity_fold_pat_lit[ENV](&ENV e, &span sp, @ast.lit lit, ann a) -> @pat {
1132+
ret @respan(sp, ast.pat_lit(lit, a));
1133+
}
1134+
11251135
fn identity_fold_pat_bind[ENV](&ENV e, &span sp, ident i, def_id did, ann a)
11261136
-> @pat {
11271137
ret @respan(sp, ast.pat_bind(i, did, a));
@@ -1373,6 +1383,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
13731383
fold_decl_item = bind identity_fold_decl_item[ENV](_,_,_),
13741384

13751385
fold_pat_wild = bind identity_fold_pat_wild[ENV](_,_,_),
1386+
fold_pat_lit = bind identity_fold_pat_lit[ENV](_,_,_,_),
13761387
fold_pat_bind = bind identity_fold_pat_bind[ENV](_,_,_,_,_),
13771388
fold_pat_tag = bind identity_fold_pat_tag[ENV](_,_,_,_,_,_),
13781389

0 commit comments

Comments
 (0)