diff options
| author | Oliver Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-04-01 09:19:29 +0200 |
|---|---|---|
| committer | Oliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de> | 2016-04-03 15:18:16 +0200 |
| commit | 913a2b4b0525c75ecf915076c4fd1e16187f8b51 (patch) | |
| tree | 84a18d70e9bf0c37e407e07fef6c34895fa439a0 /src/test/compile-fail | |
| parent | a09f386e8d1c31133f0ce1123fbeaedcff40a77d (diff) | |
| download | rust-913a2b4b0525c75ecf915076c4fd1e16187f8b51.tar.gz rust-913a2b4b0525c75ecf915076c4fd1e16187f8b51.zip | |
check constants even if they are unused in the current crate
Diffstat (limited to 'src/test/compile-fail')
| -rw-r--r-- | src/test/compile-fail/const-err-early.rs | 22 | ||||
| -rw-r--r-- | src/test/compile-fail/const-err.rs | 7 | ||||
| -rw-r--r-- | src/test/compile-fail/const-eval-span.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/const-pattern-not-const-evaluable.rs | 6 | ||||
| -rw-r--r-- | src/test/compile-fail/feature-gate-negate-unsigned.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/non-constant-enum-for-vec-repeat.rs | 2 |
6 files changed, 31 insertions, 11 deletions
diff --git a/src/test/compile-fail/const-err-early.rs b/src/test/compile-fail/const-err-early.rs new file mode 100644 index 00000000000..cdcdb919bde --- /dev/null +++ b/src/test/compile-fail/const-err-early.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_indexing)] +#![deny(const_err)] + +pub const A: i8 = -std::i8::MIN; //~ ERROR attempted to negate with overflow +pub const B: u8 = 200u8 + 200u8; //~ ERROR attempted to add with overflow +pub const C: u8 = 200u8 * 4; //~ ERROR attempted to multiply with overflow +pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR attempted to subtract with overflow +pub const E: u8 = [5u8][1]; //~ ERROR index out of bounds + +fn main() { + let _e = [6u8][1]; +} diff --git a/src/test/compile-fail/const-err.rs b/src/test/compile-fail/const-err.rs index 882e4cb2d47..45e8fc37d87 100644 --- a/src/test/compile-fail/const-err.rs +++ b/src/test/compile-fail/const-err.rs @@ -10,15 +10,11 @@ #![feature(rustc_attrs)] #![allow(exceeding_bitshifts)] -#![deny(const_err)] fn black_box<T>(_: T) { unimplemented!() } -const BLA: u8 = 200u8 + 200u8; -//~^ ERROR attempted to add with overflow - #[rustc_no_mir] // FIXME #29769 MIR overflow checking is TBD. fn main() { let a = -std::i8::MIN; @@ -30,7 +26,8 @@ fn main() { //~^ WARN attempted to multiply with overflow let d = 42u8 - (42u8 + 1); //~^ WARN attempted to subtract with overflow - let _e = BLA; + let _e = [5u8][1]; + //~^ ERROR const index-expr is out of bounds black_box(a); black_box(b); black_box(c); diff --git a/src/test/compile-fail/const-eval-span.rs b/src/test/compile-fail/const-eval-span.rs index 44ab798f491..9fdd24c42fd 100644 --- a/src/test/compile-fail/const-eval-span.rs +++ b/src/test/compile-fail/const-eval-span.rs @@ -14,7 +14,7 @@ struct S(i32); const CONSTANT: S = S(0); -//~^ ERROR: constant evaluation error: call on struct [E0080] +//~^ ERROR: unimplemented constant expression: tuple struct constructors [E0080] enum E { V = CONSTANT, diff --git a/src/test/compile-fail/const-pattern-not-const-evaluable.rs b/src/test/compile-fail/const-pattern-not-const-evaluable.rs index ecc43d21a46..4567cd4a74b 100644 --- a/src/test/compile-fail/const-pattern-not-const-evaluable.rs +++ b/src/test/compile-fail/const-pattern-not-const-evaluable.rs @@ -17,12 +17,12 @@ enum Cake { use Cake::*; const BOO: (Cake, Cake) = (Marmor, BlackForest); -//~^ ERROR: constant evaluation error: non-constant path in constant expression [E0471] +//~^ ERROR: constant evaluation error: unimplemented constant expression: enum variants [E0471] const FOO: Cake = BOO.1; const fn foo() -> Cake { - Marmor //~ ERROR: constant evaluation error: non-constant path in constant expression [E0471] - //~^ ERROR: non-constant path in constant expression + Marmor //~ ERROR: constant evaluation error: unimplemented constant expression: enum variants + //~^ ERROR: unimplemented constant expression: enum variants } const WORKS: Cake = Marmor; diff --git a/src/test/compile-fail/feature-gate-negate-unsigned.rs b/src/test/compile-fail/feature-gate-negate-unsigned.rs index 4330a4cbeab..93e09c6d8d2 100644 --- a/src/test/compile-fail/feature-gate-negate-unsigned.rs +++ b/src/test/compile-fail/feature-gate-negate-unsigned.rs @@ -17,7 +17,8 @@ impl std::ops::Neg for S { } const _MAX: usize = -1; -//~^ ERROR unary negation of unsigned integer +//~^ WARN unary negation of unsigned integer +//~| ERROR unary negation of unsigned integer //~| HELP use a cast or the `!` operator fn main() { diff --git a/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs b/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs index a7cabae16be..9564a080b8e 100644 --- a/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-enum-for-vec-repeat.rs @@ -15,5 +15,5 @@ enum State { ST_NULL, ST_WHITESPACE } fn main() { [State::ST_NULL; (State::ST_WHITESPACE as usize)]; - //~^ ERROR expected constant integer for repeat count, but non-constant path + //~^ ERROR expected constant integer for repeat count, but unimplemented constant expression } |
