about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Sullivan <sully@msully.net>2012-07-11 20:04:42 -0700
committerMichael Sullivan <sully@msully.net>2012-07-12 00:12:13 -0700
commitb569bdec9fc6637ae35148caad4823906a7829b4 (patch)
treea3888301f0170b81b990582cec56c2524cfbda5c
parent62e9ae04e26f60124f6760df26b517bce450ae41 (diff)
downloadrust-b569bdec9fc6637ae35148caad4823906a7829b4.tar.gz
rust-b569bdec9fc6637ae35148caad4823906a7829b4.zip
Refactor how we convert vstore ast types to ty types.
-rw-r--r--src/rustc/middle/typeck/astconv.rs41
1 files changed, 20 insertions, 21 deletions
diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs
index b171f9fc041..6376d7d882a 100644
--- a/src/rustc/middle/typeck/astconv.rs
+++ b/src/rustc/middle/typeck/astconv.rs
@@ -161,31 +161,30 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
         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);
-          }
 
-          // 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);
+        alt a_seq_ty.node {
+          ast::ty_vec(mt) {
+            ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, 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,