File tree 2 files changed +25
-2
lines changed 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -4289,7 +4289,8 @@ pub fn eval_repeat_count(tcx: ctxt,
4289
4289
count_expr: @ast::expr,
4290
4290
span: span)
4291
4291
-> uint {
4292
- match const_eval::eval_const_expr(tcx, count_expr) {
4292
+ match const_eval::eval_const_expr_partial(tcx, count_expr) {
4293
+ Ok(ref const_val) => match *const_val {
4293
4294
const_eval::const_int(count) => return count as uint,
4294
4295
const_eval::const_uint(count) => return count as uint,
4295
4296
const_eval::const_float(count) => {
@@ -4310,7 +4311,13 @@ pub fn eval_repeat_count(tcx: ctxt,
4310
4311
repeat count but found boolean");
4311
4312
return 0;
4312
4313
}
4313
-
4314
+ },
4315
+ Err(*) => {
4316
+ tcx.sess.span_err(span,
4317
+ ~" expected constant integer for repeat count \
4318
+ but found variable");
4319
+ return 0;
4320
+ }
4314
4321
}
4315
4322
}
4316
4323
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // Regression test for issue #3645
12
+
13
+ fn main ( ) {
14
+ let n = 1 ;
15
+ let a = ~[ 0 , ..n] ; //~ ERROR expected constant integer for repeat count but found variable
16
+ }
You can’t perform that action at this time.
0 commit comments