box patterns, expect for the trans part
This commit is contained in:
parent
6914d32acc
commit
6cb5c0980a
@ -312,6 +312,7 @@ fn arm_defnums(&ast::arm arm) -> vec[node_id] {
|
||||
case (ast::pat_rec(?fields, _)) {
|
||||
for (ast::field_pat f in fields) { walk_pat(found, f.pat); }
|
||||
}
|
||||
case (ast::pat_box(?inner)) { walk_pat(found, inner); }
|
||||
case (_) { }
|
||||
}
|
||||
}
|
||||
|
@ -311,6 +311,7 @@ fn resolve_names(&@env e, &@ast::crate c) {
|
||||
case (ast::pat_rec(?fields, _)) {
|
||||
for (ast::field_pat f in fields) { walk_pat(e, sc, f.pat); }
|
||||
}
|
||||
case (ast::pat_box(?inner)) { walk_pat(e, sc, inner); }
|
||||
case (_) { }
|
||||
}
|
||||
}
|
||||
@ -727,6 +728,7 @@ fn lookup_in_pat(&ident name, &ast::pat pat) -> option::t[def] {
|
||||
if (!option::is_none(found)) { ret found; }
|
||||
}
|
||||
}
|
||||
case (ast::pat_box(?inner)) { ret lookup_in_pat(name, *inner); }
|
||||
}
|
||||
ret none[def];
|
||||
}
|
||||
@ -1268,6 +1270,7 @@ fn check_arm(@env e, &ast::arm a, &() x, &vt[()] v) {
|
||||
case (ast::pat_rec(?fields, _)) {
|
||||
for (ast::field_pat f in fields) { walk_pat(ch, f.pat); }
|
||||
}
|
||||
case (ast::pat_box(?inner)) { walk_pat(ch, inner); }
|
||||
case (_) { }
|
||||
}
|
||||
}
|
||||
|
@ -1435,6 +1435,20 @@ fn check_pat(&@fn_ctxt fcx, &ast::pat_id_map map, &@ast::pat pat,
|
||||
}
|
||||
write::ty_only_fixup(fcx, pat.id, expected);
|
||||
}
|
||||
case (ast::pat_box(?inner)) {
|
||||
alt (structure_of(fcx, pat.span, expected)) {
|
||||
case (ty::ty_box(?e_inner)) {
|
||||
check_pat(fcx, map, inner, e_inner.ty);
|
||||
write::ty_only_fixup(fcx, pat.id, expected);
|
||||
}
|
||||
case (_) {
|
||||
fcx.ccx.tcx.sess.span_fatal
|
||||
(pat.span, "mismatched types: expected " +
|
||||
ty_to_str(fcx.ccx.tcx, expected) +
|
||||
" found box");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,6 +126,7 @@ tag pat_ {
|
||||
pat_lit(@lit);
|
||||
pat_tag(path, (@pat)[]);
|
||||
pat_rec(field_pat[], bool);
|
||||
pat_box(@pat);
|
||||
}
|
||||
|
||||
type pat_id_map = std::map::hashmap[str, ast::node_id];
|
||||
@ -143,6 +144,7 @@ fn pat_id_map(&@pat pat) -> pat_id_map {
|
||||
pat_rec(?fields, _) {
|
||||
for (field_pat f in fields) { walk(map, f.pat); }
|
||||
}
|
||||
pat_box(?inner) { walk(map, inner); }
|
||||
_ {}
|
||||
}
|
||||
}
|
||||
|
@ -292,6 +292,7 @@ fn noop_fold_pat(&pat_ p, ast_fold fld) -> pat_ {
|
||||
}
|
||||
pat_rec(fs, etc)
|
||||
}
|
||||
case (pat_box(?inner)) { pat_box(fld.fold_pat(inner)) }
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1459,6 +1459,12 @@ fn parse_pat(&parser p) -> @ast::pat {
|
||||
}
|
||||
}
|
||||
}
|
||||
case (token::AT) {
|
||||
p.bump();
|
||||
auto sub = parse_pat(p);
|
||||
pat = ast::pat_box(sub);
|
||||
hi = sub.span.hi;
|
||||
}
|
||||
case (token::LBRACE) {
|
||||
p.bump();
|
||||
auto fields = ~[];
|
||||
@ -2313,9 +2319,8 @@ fn parse_rest_import_name(&parser p, ast::ident first,
|
||||
}
|
||||
alt (p.peek()) {
|
||||
case (token::IDENT(_, _)) { identifiers += ~[parse_ident(p)]; }
|
||||
case (
|
||||
//the lexer can't tell the different kinds of stars apart ) :
|
||||
token::BINOP(token::STAR)) {
|
||||
//the lexer can't tell the different kinds of stars apart ) :
|
||||
case (token::BINOP(token::STAR)) {
|
||||
glob = true;
|
||||
p.bump();
|
||||
}
|
||||
|
@ -1136,6 +1136,10 @@ fn print_pat(&ps s, &@ast::pat pat) {
|
||||
}
|
||||
word(s.s, "}");
|
||||
}
|
||||
case (ast::pat_box(?inner)) {
|
||||
word(s.s, "@");
|
||||
print_pat(s, inner);
|
||||
}
|
||||
}
|
||||
s.ann.post(ann_node);
|
||||
}
|
||||
|
@ -200,6 +200,7 @@ fn visit_pat[E](&@pat p, &E e, &vt[E] v) {
|
||||
case (pat_rec(?fields, _)) {
|
||||
for (field_pat f in fields) { v.visit_pat(f.pat, e, v); }
|
||||
}
|
||||
case (pat_box(?inner)) { v.visit_pat(inner, e, v); }
|
||||
case (_) { }
|
||||
}
|
||||
}
|
||||
|
@ -192,6 +192,7 @@ fn walk_pat(&ast_visitor v, &@ast::pat p) {
|
||||
case (ast::pat_rec(?fields, _)) {
|
||||
for (ast::field_pat f in fields) { walk_pat(v, f.pat); }
|
||||
}
|
||||
case (ast::pat_box(?inner)) { walk_pat(v, inner); }
|
||||
case (_) { }
|
||||
}
|
||||
v.visit_pat_post(p);
|
||||
|
Loading…
x
Reference in New Issue
Block a user