Skip to content

Commit a0c550f

Browse files
author
Nick Hamann
committed
---
yaml --- r: 206718 b: refs/heads/beta c: 3c4facb h: refs/heads/master v: v3
1 parent 59b6577 commit a0c550f

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3030
refs/heads/batch: b7fd822592a4fb577552d93010c4a4e14f314346
3131
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
32-
refs/heads/beta: ed1bc684fc28d26635eed49a8a39e6c492782564
32+
refs/heads/beta: 3c4facbcfe16ea0919e7a8537cae219c14a2b1ca
3333
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3434
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
3535
refs/heads/tmp: 579e31929feff51dcaf8d444648eff8de735f91a

branches/beta/src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,8 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>,
16031603
Some(i as usize)),
16041604
_ => {
16051605
span_err!(tcx.sess, ast_ty.span, E0249,
1606-
"expected constant expr for array length");
1606+
"expected constant integer expression \
1607+
for array length");
16071608
this.tcx().types.err
16081609
}
16091610
}

branches/beta/src/librustc_typeck/diagnostics.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,38 @@ struct Foo { x: bool }
260260
261261
struct Bar<S, T> { x: Foo<S, T> }
262262
```
263+
"##,
264+
265+
E0249: r##"
266+
This error indicates a constant expression for the array length was found, but
267+
it was not an integer (signed or unsigned) expression.
268+
269+
Some examples of code that produces this error are:
270+
271+
```
272+
const A: [u32; "hello"] = []; // error
273+
const B: [u32; true] = []; // error
274+
const C: [u32; 0.0] = []; // error
275+
"##,
276+
277+
E0250: r##"
278+
This means there was an error while evaluating the expression for the length of
279+
a fixed-size array type.
280+
281+
Some examples of code that produces this error are:
282+
283+
```
284+
// divide by zero in the length expression
285+
const A: [u32; 1/0] = [];
286+
287+
// Rust currently will not evaluate the function `foo` at compile time
288+
fn foo() -> usize { 12 }
289+
const B: [u32; foo()] = [];
290+
291+
// it is an error to try to add `u8` and `f64`
292+
use std::{f64, u8};
293+
const C: [u32; u8::MAX + f64::EPSILON] = [];
294+
```
263295
"##
264296

265297
}
@@ -403,8 +435,6 @@ register_diagnostics! {
403435
E0246, // illegal recursive type
404436
E0247, // found module name used as a type
405437
E0248, // found value name used as a type
406-
E0249, // expected constant expr for array length
407-
E0250, // expected constant expr for array length
408438
E0318, // can't create default impls for traits outside their crates
409439
E0319, // trait impls for defaulted traits allowed just for structs/enums
410440
E0320, // recursive overflow during dropck

0 commit comments

Comments
 (0)