From b569bdec9fc6637ae35148caad4823906a7829b4 Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Wed, 11 Jul 2012 20:04:42 -0700 Subject: [PATCH] Refactor how we convert vstore ast types to ty types. --- src/rustc/middle/typeck/astconv.rs | 41 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index b171f9fc0414..6376d7d882ac 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -161,31 +161,30 @@ fn ast_ty_to_ty( self: AC, rscope: RS, a_seq_ty: @ast::ty, vst: ty::vstore) -> ty::t { let tcx = self.tcx(); - let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty); - alt ty::get(seq_ty).struct { - ty::ty_vec(mt) { - ret ty::mk_evec(tcx, mt, vst); + alt a_seq_ty.node { + ast::ty_vec(mt) { + ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst); } - - // HACK: if we get a ~[], we assume that it was actually a - // [] that got written down, and we throw away the /~... - ty::ty_evec(mt, vstore_uniq) { - ret ty::mk_evec(tcx, mt, vst); - } - - ty::ty_str { - ret ty::mk_estr(tcx, vst); - } - - _ { - tcx.sess.span_err( - a_seq_ty.span, - #fmt["bound not allowed on a %s", - ty::ty_sort_str(tcx, seq_ty)]); - ret seq_ty; + ast::ty_path(path, id) { + alt tcx.def_map.find(id) { + some(ast::def_prim_ty(ast::ty_str)) { + check_path_args(tcx, path, NO_TPS | NO_REGIONS); + ret ty::mk_estr(tcx, vst); + } + _ {} + } } + _ {} } + + // Get the type, just for the error message + let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty); + tcx.sess.span_err( + a_seq_ty.span, + #fmt["bound not allowed on a %s", + ty::ty_sort_str(tcx, seq_ty)]); + ret seq_ty; } fn check_path_args(tcx: ty::ctxt,