Skip to content

Commit b569bde

Browse files
committed
Refactor how we convert vstore ast types to ty types.
1 parent 62e9ae0 commit b569bde

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/rustc/middle/typeck/astconv.rs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -161,31 +161,30 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>(
161161
self: AC, rscope: RS, a_seq_ty: @ast::ty, vst: ty::vstore) -> ty::t {
162162

163163
let tcx = self.tcx();
164-
let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty);
165-
166-
alt ty::get(seq_ty).struct {
167-
ty::ty_vec(mt) {
168-
ret ty::mk_evec(tcx, mt, vst);
169-
}
170164

171-
// HACK: if we get a ~[], we assume that it was actually a
172-
// [] that got written down, and we throw away the /~...
173-
ty::ty_evec(mt, vstore_uniq) {
174-
ret ty::mk_evec(tcx, mt, vst);
165+
alt a_seq_ty.node {
166+
ast::ty_vec(mt) {
167+
ret ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst);
175168
}
176-
177-
ty::ty_str {
178-
ret ty::mk_estr(tcx, vst);
179-
}
180-
181-
_ {
182-
tcx.sess.span_err(
183-
a_seq_ty.span,
184-
#fmt["bound not allowed on a %s",
185-
ty::ty_sort_str(tcx, seq_ty)]);
186-
ret seq_ty;
169+
ast::ty_path(path, id) {
170+
alt tcx.def_map.find(id) {
171+
some(ast::def_prim_ty(ast::ty_str)) {
172+
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
173+
ret ty::mk_estr(tcx, vst);
174+
}
175+
_ {}
176+
}
187177
}
178+
_ {}
188179
}
180+
181+
// Get the type, just for the error message
182+
let seq_ty = ast_ty_to_ty(self, rscope, a_seq_ty);
183+
tcx.sess.span_err(
184+
a_seq_ty.span,
185+
#fmt["bound not allowed on a %s",
186+
ty::ty_sort_str(tcx, seq_ty)]);
187+
ret seq_ty;
189188
}
190189

191190
fn check_path_args(tcx: ty::ctxt,

0 commit comments

Comments
 (0)