Skip to content

Commit 8ad96f1

Browse files
committed
---
yaml --- r: 139066 b: refs/heads/try2 c: 42f95d0 h: refs/heads/master v: v3
1 parent 613f53e commit 8ad96f1

File tree

5 files changed

+33
-25
lines changed

5 files changed

+33
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: e67448d397ed8f468170d6fba95ceae081ece624
8+
refs/heads/try2: 42f95d055c2f22078f5c94c0d0ca229e1561ccb8
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/middle/typeck/astconv.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
use core::prelude::*;
5656

57+
use middle::const_eval;
5758
use middle::ty::{arg, field, substs};
5859
use middle::ty::{ty_param_substs_and_ty};
5960
use middle::ty;
@@ -412,9 +413,29 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
412413
}
413414
}
414415
}
415-
ast::ty_fixed_length_vec(a_mt, u) => {
416-
ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, a_mt),
417-
ty::vstore_fixed(u))
416+
ast::ty_fixed_length_vec(a_mt, e) => {
417+
match const_eval::eval_const_expr_partial(tcx, e) {
418+
Ok(ref r) => {
419+
match *r {
420+
const_eval::const_int(i) =>
421+
ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, a_mt),
422+
ty::vstore_fixed(i as uint)),
423+
const_eval::const_uint(i) =>
424+
ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, a_mt),
425+
ty::vstore_fixed(i as uint)),
426+
_ => {
427+
tcx.sess.span_fatal(
428+
ast_ty.span, ~"expected constant expr for vector length");
429+
}
430+
}
431+
}
432+
Err(ref r) => {
433+
tcx.sess.span_fatal(
434+
ast_ty.span,
435+
fmt!("expected constant expr for vector length: %s",
436+
*r));
437+
}
438+
}
418439
}
419440
ast::ty_infer => {
420441
// ty_infer should only appear as the type of arguments or return

branches/try2/src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ pub enum ty_ {
916916
ty_box(mt),
917917
ty_uniq(mt),
918918
ty_vec(mt),
919-
ty_fixed_length_vec(mt, uint),
919+
ty_fixed_length_vec(mt, @expr),
920920
ty_ptr(mt),
921921
ty_rptr(Option<@Lifetime>, mt),
922922
ty_closure(@TyClosure),

branches/try2/src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,8 @@ pub impl Parser {
642642
self.obsolete(*self.last_span, ObsoleteMutVector);
643643
}
644644

645-
// Parse the `* 3` in `[ int * 3 ]`
645+
// Parse the `* e` in `[ int * e ]`
646+
// where `e` is a const expression
646647
let t = match self.maybe_parse_fixed_vstore_with_star() {
647648
None => ty_vec(mt),
648649
Some(suffix) => ty_fixed_length_vec(mt, suffix)
@@ -814,23 +815,9 @@ pub impl Parser {
814815
})
815816
}
816817

817-
fn maybe_parse_fixed_vstore_with_star(&self) -> Option<uint> {
818+
fn maybe_parse_fixed_vstore_with_star(&self) -> Option<@ast::expr> {
818819
if self.eat(&token::BINOP(token::STAR)) {
819-
match *self.token {
820-
token::LIT_INT_UNSUFFIXED(i) if i >= 0i64 => {
821-
self.bump();
822-
Some(i as uint)
823-
}
824-
_ => {
825-
self.fatal(
826-
fmt!(
827-
"expected integral vector length \
828-
but found `%s`",
829-
token_to_str(self.reader, &copy *self.token)
830-
)
831-
);
832-
}
833-
}
820+
Some(self.parse_expr())
834821
} else {
835822
None
836823
}

branches/try2/src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
425425
}
426426
print_type(s, mt.ty);
427427
word(s.s, ~" * ");
428-
word(s.s, fmt!("%u", v));
428+
word(s.s, fmt!("%?", v));
429429
word(s.s, ~"]");
430430
}
431431
ast::ty_mac(_) => {
@@ -1015,7 +1015,7 @@ pub fn print_mac(s: @ps, m: ast::mac) {
10151015
10161016
pub fn print_vstore(s: @ps, t: ast::vstore) {
10171017
match t {
1018-
ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)),
1018+
ast::vstore_fixed(Some(i)) => word(s.s, fmt!("%?", i)),
10191019
ast::vstore_fixed(None) => word(s.s, ~"_"),
10201020
ast::vstore_uniq => word(s.s, ~"~"),
10211021
ast::vstore_box => word(s.s, ~"@"),
@@ -1028,7 +1028,7 @@ pub fn print_vstore(s: @ps, t: ast::vstore) {
10281028
10291029
pub fn print_expr_vstore(s: @ps, t: ast::expr_vstore) {
10301030
match t {
1031-
ast::expr_vstore_fixed(Some(i)) => word(s.s, fmt!("%u", i)),
1031+
ast::expr_vstore_fixed(Some(i)) => word(s.s, fmt!("%?", i)),
10321032
ast::expr_vstore_fixed(None) => word(s.s, ~"_"),
10331033
ast::expr_vstore_uniq => word(s.s, ~"~"),
10341034
ast::expr_vstore_box => word(s.s, ~"@"),

0 commit comments

Comments
 (0)