Skip to content

Commit 72e8f12

Browse files
committed
---
yaml --- r: 53947 b: refs/heads/dist-snap c: 14df844 h: refs/heads/master i: 53945: 4938227 53943: 60927cf v: v3
1 parent 56cc061 commit 72e8f12

File tree

16 files changed

+46
-128
lines changed

16 files changed

+46
-128
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
99
refs/heads/incoming: 44d4d6de762f3f9aae1fedcf454c66b79b3ad58d
10-
refs/heads/dist-snap: 58209910bd70512e4a880bb25ed296dddc48e0b7
10+
refs/heads/dist-snap: 14df8447445440794d363f6dc3fbb5220bb0a775
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librustc/driver/driver.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,15 @@ pub fn build_configuration(sess: Session, +argv0: ~str, input: input) ->
132132
}
133133

134134
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
135-
fn parse_cfgspecs(cfgspecs: ~[~str],
136-
demitter: diagnostic::Emitter) -> ast::crate_cfg {
137-
let mut meta = ~[];
135+
pub fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg {
136+
// FIXME (#2399): It would be nice to use the parser to parse all
137+
// varieties of meta_item here. At the moment we just support the
138+
// meta_word variant.
139+
let mut words = ~[];
138140
for cfgspecs.each |s| {
139-
let sess = parse::new_parse_sess(Some(demitter));
140-
let m = parse::parse_meta_from_source_str(~"cfgspec", @/*bad*/ copy *s, ~[], sess);
141-
meta.push(m)
141+
words.push(attr::mk_word_item(@/*bad*/copy *s));
142142
}
143-
return meta;
143+
return words;
144144
}
145145

146146
pub enum input {
@@ -639,7 +639,7 @@ pub fn build_session_options(+binary: ~str,
639639
let addl_lib_search_paths =
640640
getopts::opt_strs(matches, ~"L")
641641
.map(|s| Path(*s));
642-
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"), demitter);
642+
let cfg = parse_cfgspecs(getopts::opt_strs(matches, ~"cfg"));
643643
let test = opt_present(matches, ~"test");
644644
let android_cross_path = getopts::opt_maybe_str(
645645
matches, ~"android-cross-path");

branches/dist-snap/src/librustc/middle/lint.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,7 @@ fn check_item(i: @ast::item, cx: ty::ctxt) {
498498
// not traverse into subitems, since that is handled by the outer
499499
// lint visitor.
500500
fn item_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> {
501-
visit::mk_vt(@visit::Visitor {visit_item: |_i, _e, _v| { },
502-
.. **(ty_stopping_visitor(v))})
503-
}
504-
505-
fn ty_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> {
506-
visit::mk_vt(@visit::Visitor {visit_ty: |_t, _e, _v| { },.. **v})
501+
visit::mk_vt(@visit::Visitor {visit_item: |_i, _e, _v| { },.. **v})
507502
}
508503

509504
fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {

branches/dist-snap/src/librustc/middle/typeck/astconv.rs

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

5555
use core::prelude::*;
5656

57-
use middle::const_eval;
5857
use middle::ty::{arg, field, substs};
5958
use middle::ty::{ty_param_substs_and_ty};
6059
use middle::ty;
@@ -413,29 +412,9 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
413412
}
414413
}
415414
}
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-
}
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))
439418
}
440419
ast::ty_infer => {
441420
// ty_infer should only appear as the type of arguments or return

branches/dist-snap/src/librustc/middle/typeck/check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
21692169
}
21702170
ast::expr_repeat(element, count_expr, mutbl) => {
21712171
let count = ty::eval_repeat_count(tcx, count_expr);
2172-
check_expr_with_hint(fcx, count_expr, ty::mk_uint(tcx));
2172+
fcx.write_ty(count_expr.id, ty::mk_uint(tcx));
21732173
let tt = ast_expr_vstore_to_vstore(fcx, ev, count, vst);
21742174
let t: ty::t = fcx.infcx().next_ty_var();
21752175
bot |= check_expr_has_type(fcx, element, t);
@@ -2537,7 +2537,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
25372537
}
25382538
ast::expr_repeat(element, count_expr, mutbl) => {
25392539
let count = ty::eval_repeat_count(tcx, count_expr);
2540-
check_expr_with_hint(fcx, count_expr, ty::mk_uint(tcx));
2540+
fcx.write_ty(count_expr.id, ty::mk_uint(tcx));
25412541
let t: ty::t = fcx.infcx().next_ty_var();
25422542
bot |= check_expr_has_type(fcx, element, t);
25432543
let t = ty::mk_evec(tcx, ty::mt {ty: t, mutbl: mutbl},

branches/dist-snap/src/libsyntax/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ pub enum vstore {
386386
#[auto_decode]
387387
#[deriving_eq]
388388
pub enum expr_vstore {
389+
// FIXME (#3469): Change uint to @expr (actually only constant exprs)
389390
expr_vstore_fixed(Option<uint>), // [1,2,3,4]
390391
expr_vstore_uniq, // ~[1,2,3,4]
391392
expr_vstore_box, // @[1,2,3,4]
@@ -915,7 +916,7 @@ pub enum ty_ {
915916
ty_box(mt),
916917
ty_uniq(mt),
917918
ty_vec(mt),
918-
ty_fixed_length_vec(mt, @expr),
919+
ty_fixed_length_vec(mt, uint),
919920
ty_ptr(mt),
920921
ty_rptr(Option<@Lifetime>, mt),
921922
ty_closure(@TyClosure),

branches/dist-snap/src/libsyntax/ext/expand.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ pub fn core_macros() -> ~str {
456456
if !$cond {
457457
::core::sys::fail_assert(stringify!($cond), file!(), line!())
458458
}
459+
};
460+
($cond:expr, $msg:expr) => {
461+
if !$cond {
462+
::core::sys::fail_assert($msg, file!(), line!())
463+
}
459464
}
460465
)
461466

branches/dist-snap/src/libsyntax/fold.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
622622
}
623623
ty_tup(ref tys) => ty_tup(tys.map(|ty| fld.fold_ty(*ty))),
624624
ty_path(path, id) => ty_path(fld.fold_path(path), fld.new_id(id)),
625-
ty_fixed_length_vec(ref mt, e) => {
625+
ty_fixed_length_vec(ref mt, vs) => {
626626
ty_fixed_length_vec(
627627
fold_mt(mt, fld),
628-
fld.fold_expr(e)
628+
vs
629629
)
630630
}
631631
ty_mac(ref mac) => ty_mac(fold_mac(*mac))

branches/dist-snap/src/libsyntax/parse/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,22 +139,6 @@ pub fn parse_item_from_source_str(
139139
maybe_aborted(p.parse_item(attrs),p)
140140
}
141141

142-
pub fn parse_meta_from_source_str(
143-
name: ~str,
144-
source: @~str,
145-
+cfg: ast::crate_cfg,
146-
sess: @mut ParseSess
147-
) -> @ast::meta_item {
148-
let p = new_parser_from_source_str(
149-
sess,
150-
cfg,
151-
/*bad*/ copy name,
152-
codemap::FssNone,
153-
source
154-
);
155-
maybe_aborted(p.parse_meta_item(),p)
156-
}
157-
158142
pub fn parse_stmt_from_source_str(
159143
name: ~str,
160144
source: @~str,

branches/dist-snap/src/libsyntax/parse/parser.rs

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

645-
// Parse the `* e` in `[ int * e ]`
646-
// where `e` is a const expression
645+
// Parse the `* 3` in `[ int * 3 ]`
647646
let t = match self.maybe_parse_fixed_vstore_with_star() {
648647
None => ty_vec(mt),
649648
Some(suffix) => ty_fixed_length_vec(mt, suffix)
@@ -815,9 +814,23 @@ pub impl Parser {
815814
})
816815
}
817816

818-
fn maybe_parse_fixed_vstore_with_star(&self) -> Option<@ast::expr> {
817+
fn maybe_parse_fixed_vstore_with_star(&self) -> Option<uint> {
819818
if self.eat(&token::BINOP(token::STAR)) {
820-
Some(self.parse_expr())
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+
}
821834
} else {
822835
None
823836
}

branches/dist-snap/src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
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-
print_expr(s, v);
428+
word(s.s, fmt!("%u", v));
429429
word(s.s, ~"]");
430430
}
431431
ast::ty_mac(_) => {

branches/dist-snap/src/libsyntax/visit.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,7 @@ pub fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) {
246246
(v.visit_ty)(f.decl.output, e, v);
247247
},
248248
ty_path(p, _) => visit_path(p, e, v),
249-
ty_fixed_length_vec(ref mt, ex) => {
250-
(v.visit_ty)(mt.ty, e, v);
251-
(v.visit_expr)(ex, e, v);
252-
},
249+
ty_fixed_length_vec(ref mt, _) => (v.visit_ty)(mt.ty, e, v),
253250
ty_nil | ty_bot | ty_mac(_) | ty_infer => ()
254251
}
255252
}

branches/dist-snap/src/test/compile-fail/non-constant-expr-for-fixed-len-vec.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

branches/dist-snap/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,11 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Check that constant expressions can be used in vec repeat syntax.
11+
// error-pattern:custom message
1212

1313
fn main() {
14-
15-
const FOO: int = 2;
16-
let _v = [0, ..FOO*3*2/2];
17-
14+
fail_unless!(false, "custom message");
1815
}

branches/dist-snap/src/test/run-pass/const-expr-in-fixed-length-vec.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)