aboutsummaryrefslogtreecommitdiff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <[email protected]>2010-12-10 17:24:53 -0800
committerPatrick Walton <[email protected]>2010-12-10 17:24:53 -0800
commit0d43c198f0d1b8dd9ff180afb24ded7c98d3bae7 (patch)
tree167d941acd7aa19f4e7dc1ac37f27d9ae18a78b9 /src/comp
parentrustc: Add tag support to ty_of_item in typeck (diff)
downloadrust-0d43c198f0d1b8dd9ff180afb24ded7c98d3bae7.tar.xz
rust-0d43c198f0d1b8dd9ff180afb24ded7c98d3bae7.zip
rustc: Add def ids to pattern bindings
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/front/ast.rs2
-rw-r--r--src/comp/front/parser.rs2
-rw-r--r--src/comp/middle/fold.rs13
3 files changed, 9 insertions, 8 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 553a49f6..71065150 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -46,7 +46,7 @@ type block_ = rec(vec[@stmt] stmts,
type pat = spanned[pat_];
tag pat_ {
pat_wild(ann);
- pat_bind(ident, ann);
+ pat_bind(ident, def_id, ann);
pat_tag(ident, vec[@pat], ann);
}
diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs
index dd5df9b5..f8db2f71 100644
--- a/src/comp/front/parser.rs
+++ b/src/comp/front/parser.rs
@@ -883,7 +883,7 @@ impure fn parse_pat(parser p) -> @ast.pat {
alt (p.peek()) {
case (token.IDENT(?id)) {
p.bump();
- pat = ast.pat_bind(id, ast.ann_none);
+ pat = ast.pat_bind(id, p.next_def_id(), ast.ann_none);
}
case (?tok) {
p.err("expected identifier after '?' in pattern but " +
diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs
index c81d2785..da2415b7 100644
--- a/src/comp/middle/fold.rs
+++ b/src/comp/middle/fold.rs
@@ -145,7 +145,7 @@ type ast_fold[ENV] =
ann a) -> @pat) fold_pat_wild,
(fn(&ENV e, &span sp,
- ident i, ann a) -> @pat) fold_pat_bind,
+ ident i, def_id did, ann a) -> @pat) fold_pat_bind,
(fn(&ENV e, &span sp,
ident i, vec[@pat] args,
@@ -340,8 +340,8 @@ fn fold_pat[ENV](&ENV env, ast_fold[ENV] fld, @ast.pat p) -> @ast.pat {
alt (p.node) {
case (ast.pat_wild(?t)) { ret fld.fold_pat_wild(env_, p.span, t); }
- case (ast.pat_bind(?id, ?t)) {
- ret fld.fold_pat_bind(env_, p.span, id, t);
+ case (ast.pat_bind(?id, ?did, ?t)) {
+ ret fld.fold_pat_bind(env_, p.span, id, did, t);
}
case (ast.pat_tag(?id, ?pats, ?t)) {
let vec[@ast.pat] ppats = vec();
@@ -852,8 +852,9 @@ fn identity_fold_pat_wild[ENV](&ENV e, &span sp, ann a) -> @pat {
ret @respan(sp, ast.pat_wild(a));
}
-fn identity_fold_pat_bind[ENV](&ENV e, &span sp, ident i, ann a) -> @pat {
- ret @respan(sp, ast.pat_bind(i, a));
+fn identity_fold_pat_bind[ENV](&ENV e, &span sp, ident i, def_id did, ann a)
+ -> @pat {
+ ret @respan(sp, ast.pat_bind(i, did, a));
}
fn identity_fold_pat_tag[ENV](&ENV e, &span sp, ident i, vec[@pat] args,
@@ -1029,7 +1030,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] {
fold_decl_item = bind identity_fold_decl_item[ENV](_,_,_),
fold_pat_wild = bind identity_fold_pat_wild[ENV](_,_,_),
- fold_pat_bind = bind identity_fold_pat_bind[ENV](_,_,_,_),
+ fold_pat_bind = bind identity_fold_pat_bind[ENV](_,_,_,_,_),
fold_pat_tag = bind identity_fold_pat_tag[ENV](_,_,_,_,_),
fold_stmt_decl = bind identity_fold_stmt_decl[ENV](_,_,_),