Parse unique box types

Issue #409
This commit is contained in:
Brian Anderson 2011-09-20 16:07:09 -07:00
parent be1feaa918
commit 865dcb663d
6 changed files with 18 additions and 0 deletions

View File

@ -285,6 +285,9 @@ fn ast_ty_to_ty(tcx: ty::ctxt, getter: ty_getter, ast_ty: @ast::ty) -> ty::t {
ast::ty_box(mt) {
typ = ty::mk_box(tcx, ast_mt_to_mt(tcx, getter, mt));
}
ast::ty_uniq(mt) {
typ = ty::mk_uniq(tcx, ast_ty_to_ty(tcx, getter, mt.ty));
}
ast::ty_vec(mt) {
typ = ty::mk_vec(tcx, ast_mt_to_mt(tcx, getter, mt));
}

View File

@ -307,6 +307,7 @@ tag ty_ {
ty_char;
ty_str;
ty_box(mt);
ty_uniq(mt);
ty_vec(mt);
ty_ptr(mt);
ty_task;

View File

@ -540,6 +540,11 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
let mt = parse_mt(p);
hi = mt.ty.span.hi;
t = ast::ty_box(mt);
} else if p.peek() == token::TILDE {
p.bump();
let mt = parse_mt(p);
hi = mt.ty.span.hi;
t = ast::ty_uniq(mt);
} else if p.peek() == token::BINOP(token::STAR) {
p.bump();
let mt = parse_mt(p);

View File

@ -260,6 +260,7 @@ fn print_type(s: ps, ty: @ast::ty) {
ast::ty_char. { word(s.s, "char"); }
ast::ty_str. { word(s.s, "str"); }
ast::ty_box(mt) { word(s.s, "@"); print_mt(s, mt); }
ast::ty_uniq(mt) { word(s.s, "~"); print_mt(s, mt); }
ast::ty_vec(mt) {
word(s.s, "[");
alt mt.mut {

View File

@ -121,6 +121,7 @@ fn visit_ty<E>(t: @ty, e: E, v: vt<E>) {
ty_char. {/* no-op */ }
ty_str. {/* no-op */ }
ty_box(mt) { v.visit_ty(mt.ty, e, v); }
ty_uniq(mt) { v.visit_ty(mt.ty, e, v); }
ty_vec(mt) { v.visit_ty(mt.ty, e, v); }
ty_ptr(mt) { v.visit_ty(mt.ty, e, v); }
ty_port(t) { v.visit_ty(t, e, v); }

View File

@ -0,0 +1,7 @@
fn main() {
let _: ~int;
}
fn f(i: ~int) -> ~int {
fail;
}