Merge ConstVal and ConstValue

This commit is contained in:
Oliver Schneider 2018-06-25 20:53:02 +02:00
parent 221a499bf1
commit 4bb9648b27
35 changed files with 204 additions and 341 deletions

View file

@ -11,19 +11,24 @@
#![deny(const_err)]
pub const A: i8 = -std::i8::MIN;
//~^ ERROR E0080
//~| ERROR attempt to negate with overflow
//~^ ERROR attempt to negate with overflow
//~| ERROR this expression will panic at runtime
//~| ERROR this constant cannot be used
pub const B: i8 = A;
//~^ ERROR const_err
//~| ERROR const_err
//~| ERROR const_err
//~| ERROR const_err
pub const C: u8 = A as u8;
//~^ ERROR const_err
//~| ERROR const_err
//~| ERROR const_err
//~| ERROR const_err
pub const D: i8 = 50 - A;
//~^ ERROR const_err
//~| ERROR const_err
//~| ERROR const_err
//~| ERROR const_err
fn main() {
let _ = (A, B, C, D);

View file

@ -23,7 +23,6 @@ fn black_box<T>(_: T) {
// Make sure that the two uses get two errors.
const FOO: u8 = [5u8][1];
//~^ ERROR constant evaluation error
//~| ERROR constant evaluation error
//~| index out of bounds: the len is 1 but the index is 1
fn main() {

View file

@ -15,11 +15,12 @@
const ONE: usize = 1;
const TWO: usize = 2;
const LEN: usize = ONE - TWO;
//~^ ERROR E0080
//~| ERROR attempt to subtract with overflow
//~^ ERROR attempt to subtract with overflow
fn main() {
let a: [i8; LEN] = unimplemented!();
//~^ ERROR E0080
//~| ERROR E0080
//~| ERROR const_err
//~| ERROR const_err
}

View file

@ -6,14 +6,23 @@ LL | const LEN: usize = ONE - TWO;
|
= note: #[deny(const_err)] on by default
error[E0080]: constant evaluation error
--> $DIR/const-len-underflow-separate-spans.rs:17:20
error: referenced constant
--> $DIR/const-len-underflow-separate-spans.rs:21:17
|
LL | const LEN: usize = ONE - TWO;
| ^^^^^^^^^ attempt to subtract with overflow
| --------- attempt to subtract with overflow
...
LL | let a: [i8; LEN] = unimplemented!();
| ^^^
error: this expression will panic at runtime
--> $DIR/const-len-underflow-separate-spans.rs:21:17
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^ referenced constant has errors
error[E0080]: referenced constant
--> $DIR/const-len-underflow-separate-spans.rs:22:12
--> $DIR/const-len-underflow-separate-spans.rs:21:12
|
LL | const LEN: usize = ONE - TWO;
| --------- attempt to subtract with overflow
@ -22,13 +31,13 @@ LL | let a: [i8; LEN] = unimplemented!();
| ^^^^^^^^^
error[E0080]: could not evaluate constant expression
--> $DIR/const-len-underflow-separate-spans.rs:22:12
--> $DIR/const-len-underflow-separate-spans.rs:21:12
|
LL | let a: [i8; LEN] = unimplemented!();
| ^^^^^---^
| |
| referenced constant has errors
error: aborting due to 4 previous errors
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0080`.