diff options
| author | bors <bors@rust-lang.org> | 2018-06-28 22:20:14 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-06-28 22:20:14 +0000 |
| commit | 57dd722606028cafde656a66edc3206b82cd3bab (patch) | |
| tree | 8f515fb881d43a4874d3010c91b92696faafcd1f /src/test | |
| parent | e3bf634e060bc2f8665878288bcea02008ca346e (diff) | |
| parent | 3332c0c7e18a0669fd61d079e74c3d891033c32e (diff) | |
Auto merge of #51884 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 6 pull requests Successful merges: - #51636 (Refactor error reporting of constants) - #51765 (Use assert_eq! in copy_from_slice) - #51822 (Provide existing ref suggestions for more E0308 errors) - #51839 (Detect overflows of non u32 shifts) - #51868 (Remove process::id from 'Stabilized APIs' in 1.27.0 release notes) - #51875 (Explicitely disable WASM code generation for Emscripten) Failed merges: r? @ghost
Diffstat (limited to 'src/test')
25 files changed, 142 insertions, 195 deletions
diff --git a/src/test/compile-fail/const-err-early.rs b/src/test/compile-fail/const-err-early.rs index 92c6b1fd0b5..39b1b342eac 100644 --- a/src/test/compile-fail/const-err-early.rs +++ b/src/test/compile-fail/const-err-early.rs @@ -11,16 +11,10 @@ #![deny(const_err)] pub const A: i8 = -std::i8::MIN; //~ ERROR const_err -//~^ ERROR this constant cannot be used -//~| ERROR this expression will panic at runtime pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err -//~^ ERROR this constant cannot be used pub const C: u8 = 200u8 * 4; //~ ERROR const_err -//~^ ERROR this constant cannot be used pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err -//~^ ERROR this constant cannot be used pub const E: u8 = [5u8][1]; //~ ERROR const_err -//~| ERROR this constant cannot be used fn main() { let _a = A; diff --git a/src/test/compile-fail/const-err-multi.rs b/src/test/compile-fail/const-err-multi.rs index 4a5e78b381e..f2ee8a7078c 100644 --- a/src/test/compile-fail/const-err-multi.rs +++ b/src/test/compile-fail/const-err-multi.rs @@ -11,10 +11,7 @@ #![deny(const_err)] pub const A: i8 = -std::i8::MIN; -//~^ ERROR E0080 -//~| ERROR attempt to negate with overflow -//~| ERROR this expression will panic at runtime -//~| ERROR this constant cannot be used +//~^ ERROR this constant cannot be used pub const B: i8 = A; //~^ ERROR const_err //~| ERROR const_err diff --git a/src/test/compile-fail/const-err.rs b/src/test/compile-fail/const-err.rs index f77603b3eba..8683f6a0231 100644 --- a/src/test/compile-fail/const-err.rs +++ b/src/test/compile-fail/const-err.rs @@ -23,9 +23,10 @@ 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() { black_box((FOO, FOO)); + //~^ ERROR referenced constant has errors + //~| ERROR could not evaluate constant } diff --git a/src/test/compile-fail/const-eval-overflow2.rs b/src/test/compile-fail/const-eval-overflow2.rs index 7b5db7a4f6d..88fc5182775 100644 --- a/src/test/compile-fail/const-eval-overflow2.rs +++ b/src/test/compile-fail/const-eval-overflow2.rs @@ -25,54 +25,46 @@ const VALS_I8: (i8,) = //~^ ERROR this constant cannot be used ( i8::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_I16: (i16,) = //~^ ERROR this constant cannot be used ( i16::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_I32: (i32,) = //~^ ERROR this constant cannot be used ( i32::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_I64: (i64,) = //~^ ERROR this constant cannot be used ( i64::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_U8: (u8,) = //~^ ERROR this constant cannot be used ( u8::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_U16: (u16,) = ( //~^ ERROR this constant cannot be used u16::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_U32: (u32,) = ( //~^ ERROR this constant cannot be used u32::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); const VALS_U64: (u64,) = //~^ ERROR this constant cannot be used ( u64::MIN - 1, - //~^ ERROR attempt to subtract with overflow ); fn main() { diff --git a/src/test/compile-fail/const-eval-overflow2b.rs b/src/test/compile-fail/const-eval-overflow2b.rs index ce4dc72555d..1878daea931 100644 --- a/src/test/compile-fail/const-eval-overflow2b.rs +++ b/src/test/compile-fail/const-eval-overflow2b.rs @@ -25,54 +25,46 @@ const VALS_I8: (i8,) = //~^ ERROR this constant cannot be used ( i8::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_I16: (i16,) = //~^ ERROR this constant cannot be used ( i16::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_I32: (i32,) = //~^ ERROR this constant cannot be used ( i32::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_I64: (i64,) = //~^ ERROR this constant cannot be used ( i64::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_U8: (u8,) = //~^ ERROR this constant cannot be used ( u8::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_U16: (u16,) = ( //~^ ERROR this constant cannot be used u16::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_U32: (u32,) = ( //~^ ERROR this constant cannot be used u32::MAX + 1, - //~^ ERROR attempt to add with overflow ); const VALS_U64: (u64,) = //~^ ERROR this constant cannot be used ( u64::MAX + 1, - //~^ ERROR attempt to add with overflow ); fn main() { diff --git a/src/test/compile-fail/const-eval-overflow2c.rs b/src/test/compile-fail/const-eval-overflow2c.rs index 88eb14a1330..f3d28295bf8 100644 --- a/src/test/compile-fail/const-eval-overflow2c.rs +++ b/src/test/compile-fail/const-eval-overflow2c.rs @@ -25,54 +25,46 @@ const VALS_I8: (i8,) = //~^ ERROR this constant cannot be used ( i8::MIN * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_I16: (i16,) = //~^ ERROR this constant cannot be used ( i16::MIN * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_I32: (i32,) = //~^ ERROR this constant cannot be used ( i32::MIN * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_I64: (i64,) = //~^ ERROR this constant cannot be used ( i64::MIN * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_U8: (u8,) = //~^ ERROR this constant cannot be used ( u8::MAX * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_U16: (u16,) = ( //~^ ERROR this constant cannot be used u16::MAX * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_U32: (u32,) = ( //~^ ERROR this constant cannot be used u32::MAX * 2, - //~^ ERROR attempt to multiply with overflow ); const VALS_U64: (u64,) = //~^ ERROR this constant cannot be used ( u64::MAX * 2, - //~^ ERROR attempt to multiply with overflow ); fn main() { diff --git a/src/test/ui/const-eval/conditional_array_execution.nll.stderr b/src/test/ui/const-eval/conditional_array_execution.nll.stderr index 3580950854d..8bc302a2bef 100644 --- a/src/test/ui/const-eval/conditional_array_execution.nll.stderr +++ b/src/test/ui/const-eval/conditional_array_execution.nll.stderr @@ -1,8 +1,10 @@ -warning: attempt to subtract with overflow - --> $DIR/conditional_array_execution.rs:15:19 +warning: this constant cannot be used + --> $DIR/conditional_array_execution.rs:15:1 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | attempt to subtract with overflow | note: lint level defined here --> $DIR/conditional_array_execution.rs:11:9 @@ -10,16 +12,8 @@ note: lint level defined here LL | #![warn(const_err)] | ^^^^^^^^^ -warning: this constant cannot be used - --> $DIR/conditional_array_execution.rs:15:1 - | -LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | attempt to subtract with overflow - -warning: referenced constant - --> $DIR/conditional_array_execution.rs:20:20 +warning: referenced constant has errors + --> $DIR/conditional_array_execution.rs:19:20 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ----- attempt to subtract with overflow @@ -28,13 +22,13 @@ LL | println!("{}", FOO); | ^^^ warning: this expression will panic at runtime - --> $DIR/conditional_array_execution.rs:20:20 + --> $DIR/conditional_array_execution.rs:19:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/conditional_array_execution.rs:20:5 +error[E0080]: referenced constant has errors + --> $DIR/conditional_array_execution.rs:19:5 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ----- attempt to subtract with overflow @@ -45,7 +39,7 @@ LL | println!("{}", FOO); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/conditional_array_execution.rs:20:5 + --> $DIR/conditional_array_execution.rs:19:5 | LL | println!("{}", FOO); | ^^^^^^^^^^^^^^^---^^ @@ -54,8 +48,8 @@ LL | println!("{}", FOO); | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error[E0080]: referenced constant - --> $DIR/conditional_array_execution.rs:20:20 +error[E0080]: referenced constant has errors + --> $DIR/conditional_array_execution.rs:19:20 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ----- attempt to subtract with overflow @@ -64,7 +58,7 @@ LL | println!("{}", FOO); | ^^^ error[E0080]: erroneous constant used - --> $DIR/conditional_array_execution.rs:20:20 + --> $DIR/conditional_array_execution.rs:19:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors diff --git a/src/test/ui/const-eval/conditional_array_execution.rs b/src/test/ui/const-eval/conditional_array_execution.rs index ac555b25afd..99487eb4979 100644 --- a/src/test/ui/const-eval/conditional_array_execution.rs +++ b/src/test/ui/const-eval/conditional_array_execution.rs @@ -13,8 +13,7 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; -//~^ WARN attempt to subtract with overflow -//~| WARN this constant cannot be used +//~^ WARN this constant cannot be used fn main() { println!("{}", FOO); diff --git a/src/test/ui/const-eval/conditional_array_execution.stderr b/src/test/ui/const-eval/conditional_array_execution.stderr index 64010c946a7..649da03a5e7 100644 --- a/src/test/ui/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/const-eval/conditional_array_execution.stderr @@ -1,8 +1,10 @@ -warning: attempt to subtract with overflow - --> $DIR/conditional_array_execution.rs:15:19 +warning: this constant cannot be used + --> $DIR/conditional_array_execution.rs:15:1 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | attempt to subtract with overflow | note: lint level defined here --> $DIR/conditional_array_execution.rs:11:9 @@ -10,16 +12,8 @@ note: lint level defined here LL | #![warn(const_err)] | ^^^^^^^^^ -warning: this constant cannot be used - --> $DIR/conditional_array_execution.rs:15:1 - | -LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | attempt to subtract with overflow - -warning: referenced constant - --> $DIR/conditional_array_execution.rs:20:20 +warning: referenced constant has errors + --> $DIR/conditional_array_execution.rs:19:20 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ----- attempt to subtract with overflow @@ -28,13 +22,13 @@ LL | println!("{}", FOO); | ^^^ warning: this expression will panic at runtime - --> $DIR/conditional_array_execution.rs:20:20 + --> $DIR/conditional_array_execution.rs:19:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/conditional_array_execution.rs:20:20 +error[E0080]: referenced constant has errors + --> $DIR/conditional_array_execution.rs:19:20 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ----- attempt to subtract with overflow @@ -43,7 +37,7 @@ LL | println!("{}", FOO); | ^^^ error[E0080]: erroneous constant used - --> $DIR/conditional_array_execution.rs:20:20 + --> $DIR/conditional_array_execution.rs:19:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors diff --git a/src/test/ui/const-eval/issue-43197.nll.stderr b/src/test/ui/const-eval/issue-43197.nll.stderr index 3bde12ade90..5819e6a9254 100644 --- a/src/test/ui/const-eval/issue-43197.nll.stderr +++ b/src/test/ui/const-eval/issue-43197.nll.stderr @@ -1,15 +1,3 @@ -warning: attempt to subtract with overflow - --> $DIR/issue-43197.rs:20:20 - | -LL | const X: u32 = 0-1; - | ^^^ - | -note: lint level defined here - --> $DIR/issue-43197.rs:11:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - warning: this constant cannot be used --> $DIR/issue-43197.rs:20:5 | @@ -17,23 +5,23 @@ LL | const X: u32 = 0-1; | ^^^^^^^^^^^^^^^---^ | | | attempt to subtract with overflow - -warning: attempt to subtract with overflow - --> $DIR/issue-43197.rs:23:24 | -LL | const Y: u32 = foo(0-1); - | ^^^ +note: lint level defined here + --> $DIR/issue-43197.rs:11:9 + | +LL | #![warn(const_err)] + | ^^^^^^^^^ warning: this constant cannot be used - --> $DIR/issue-43197.rs:23:5 + --> $DIR/issue-43197.rs:22:5 | LL | const Y: u32 = foo(0-1); | ^^^^^^^^^^^^^^^^^^^---^^ | | | attempt to subtract with overflow -warning: referenced constant - --> $DIR/issue-43197.rs:26:23 +warning: referenced constant has errors + --> $DIR/issue-43197.rs:24:23 | LL | const X: u32 = 0-1; | --- attempt to subtract with overflow @@ -42,28 +30,28 @@ LL | println!("{} {}", X, Y); | ^ warning: this expression will panic at runtime - --> $DIR/issue-43197.rs:26:23 + --> $DIR/issue-43197.rs:24:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors -warning: referenced constant - --> $DIR/issue-43197.rs:26:26 +warning: referenced constant has errors + --> $DIR/issue-43197.rs:24:26 | LL | const Y: u32 = foo(0-1); | --- attempt to subtract with overflow -... +LL | //~^ WARN this constant cannot be used LL | println!("{} {}", X, Y); | ^ warning: this expression will panic at runtime - --> $DIR/issue-43197.rs:26:26 + --> $DIR/issue-43197.rs:24:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/issue-43197.rs:26:5 +error[E0080]: referenced constant has errors + --> $DIR/issue-43197.rs:24:5 | LL | const X: u32 = 0-1; | --- attempt to subtract with overflow @@ -74,7 +62,7 @@ LL | println!("{} {}", X, Y); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:26:5 + --> $DIR/issue-43197.rs:24:5 | LL | println!("{} {}", X, Y); | ^^^^^^^^^^^^^^^^^^-^^^^^ @@ -83,23 +71,23 @@ LL | println!("{} {}", X, Y); | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error[E0080]: referenced constant - --> $DIR/issue-43197.rs:26:26 +error[E0080]: referenced constant has errors + --> $DIR/issue-43197.rs:24:26 | LL | const Y: u32 = foo(0-1); | --- attempt to subtract with overflow -... +LL | //~^ WARN this constant cannot be used LL | println!("{} {}", X, Y); | ^ error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:26:26 + --> $DIR/issue-43197.rs:24:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/issue-43197.rs:26:23 +error[E0080]: referenced constant has errors + --> $DIR/issue-43197.rs:24:23 | LL | const X: u32 = 0-1; | --- attempt to subtract with overflow @@ -108,7 +96,7 @@ LL | println!("{} {}", X, Y); | ^ error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:26:23 + --> $DIR/issue-43197.rs:24:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors diff --git a/src/test/ui/const-eval/issue-43197.rs b/src/test/ui/const-eval/issue-43197.rs index 03aa65eb274..9304af7b811 100644 --- a/src/test/ui/const-eval/issue-43197.rs +++ b/src/test/ui/const-eval/issue-43197.rs @@ -18,11 +18,9 @@ const fn foo(x: u32) -> u32 { fn main() { const X: u32 = 0-1; - //~^ WARN attempt to subtract with overflow - //~| WARN this constant cannot be used + //~^ WARN this constant cannot be used const Y: u32 = foo(0-1); - //~^ WARN attempt to subtract with overflow - //~| WARN this constant cannot be used + //~^ WARN this constant cannot be used println!("{} {}", X, Y); //~^ WARN this expression will panic at runtime //~| WARN this expression will panic at runtime diff --git a/src/test/ui/const-eval/issue-43197.stderr b/src/test/ui/const-eval/issue-43197.stderr index 071d8787307..bf864d81ea3 100644 --- a/src/test/ui/const-eval/issue-43197.stderr +++ b/src/test/ui/const-eval/issue-43197.stderr @@ -1,15 +1,3 @@ -warning: attempt to subtract with overflow - --> $DIR/issue-43197.rs:20:20 - | -LL | const X: u32 = 0-1; - | ^^^ - | -note: lint level defined here - --> $DIR/issue-43197.rs:11:9 - | -LL | #![warn(const_err)] - | ^^^^^^^^^ - warning: this constant cannot be used --> $DIR/issue-43197.rs:20:5 | @@ -17,23 +5,23 @@ LL | const X: u32 = 0-1; | ^^^^^^^^^^^^^^^---^ | | | attempt to subtract with overflow - -warning: attempt to subtract with overflow - --> $DIR/issue-43197.rs:23:24 | -LL | const Y: u32 = foo(0-1); - | ^^^ +note: lint level defined here + --> $DIR/issue-43197.rs:11:9 + | +LL | #![warn(const_err)] + | ^^^^^^^^^ warning: this constant cannot be used - --> $DIR/issue-43197.rs:23:5 + --> $DIR/issue-43197.rs:22:5 | LL | const Y: u32 = foo(0-1); | ^^^^^^^^^^^^^^^^^^^---^^ | | | attempt to subtract with overflow -warning: referenced constant - --> $DIR/issue-43197.rs:26:23 +warning: referenced constant has errors + --> $DIR/issue-43197.rs:24:23 | LL | const X: u32 = 0-1; | --- attempt to subtract with overflow @@ -42,43 +30,43 @@ LL | println!("{} {}", X, Y); | ^ warning: this expression will panic at runtime - --> $DIR/issue-43197.rs:26:23 + --> $DIR/issue-43197.rs:24:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors -warning: referenced constant - --> $DIR/issue-43197.rs:26:26 +warning: referenced constant has errors + --> $DIR/issue-43197.rs:24:26 | LL | const Y: u32 = foo(0-1); | --- attempt to subtract with overflow -... +LL | //~^ WARN this constant cannot be used LL | println!("{} {}", X, Y); | ^ warning: this expression will panic at runtime - --> $DIR/issue-43197.rs:26:26 + --> $DIR/issue-43197.rs:24:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/issue-43197.rs:26:26 +error[E0080]: referenced constant has errors + --> $DIR/issue-43197.rs:24:26 | LL | const Y: u32 = foo(0-1); | --- attempt to subtract with overflow -... +LL | //~^ WARN this constant cannot be used LL | println!("{} {}", X, Y); | ^ error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:26:26 + --> $DIR/issue-43197.rs:24:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/issue-43197.rs:26:23 +error[E0080]: referenced constant has errors + --> $DIR/issue-43197.rs:24:23 | LL | const X: u32 = 0-1; | --- attempt to subtract with overflow @@ -87,7 +75,7 @@ LL | println!("{} {}", X, Y); | ^ error[E0080]: erroneous constant used - --> $DIR/issue-43197.rs:26:23 + --> $DIR/issue-43197.rs:24:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors diff --git a/src/test/ui/const-eval/issue-44578.nll.stderr b/src/test/ui/const-eval/issue-44578.nll.stderr index ad4f08966c0..eeb152e00ea 100644 --- a/src/test/ui/const-eval/issue-44578.nll.stderr +++ b/src/test/ui/const-eval/issue-44578.nll.stderr @@ -1,4 +1,4 @@ -error[E0080]: referenced constant +error[E0080]: referenced constant has errors --> $DIR/issue-44578.rs:35:5 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; @@ -19,7 +19,7 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error[E0080]: referenced constant +error[E0080]: referenced constant has errors --> $DIR/issue-44578.rs:35:20 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; diff --git a/src/test/ui/const-eval/issue-44578.stderr b/src/test/ui/const-eval/issue-44578.stderr index 28a723a069e..06174f37dca 100644 --- a/src/test/ui/const-eval/issue-44578.stderr +++ b/src/test/ui/const-eval/issue-44578.stderr @@ -1,4 +1,4 @@ -error[E0080]: referenced constant +error[E0080]: referenced constant has errors --> $DIR/issue-44578.rs:35:20 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; diff --git a/src/test/ui/const-eval/issue-50814-2.stderr b/src/test/ui/const-eval/issue-50814-2.stderr index 3c59cb0e2bc..1e37e949812 100644 --- a/src/test/ui/const-eval/issue-50814-2.stderr +++ b/src/test/ui/const-eval/issue-50814-2.stderr @@ -1,4 +1,4 @@ -error[E0080]: referenced constant +error[E0080]: referenced constant has errors --> $DIR/issue-50814-2.rs:26:5 | LL | const BAR: usize = [5, 6, 7][T::BOO]; diff --git a/src/test/ui/const-eval/issue-50814.stderr b/src/test/ui/const-eval/issue-50814.stderr index 145279ccc03..16160207c57 100644 --- a/src/test/ui/const-eval/issue-50814.stderr +++ b/src/test/ui/const-eval/issue-50814.stderr @@ -1,4 +1,4 @@ -error[E0080]: referenced constant +error[E0080]: referenced constant has errors --> $DIR/issue-50814.rs:27:5 | LL | const MAX: u8 = A::MAX + B::MAX; diff --git a/src/test/ui/const-eval/pub_const_err.rs b/src/test/ui/const-eval/pub_const_err.rs index ef8fdb33d74..b7cfa949bac 100644 --- a/src/test/ui/const-eval/pub_const_err.rs +++ b/src/test/ui/const-eval/pub_const_err.rs @@ -14,8 +14,7 @@ #![crate_type = "lib"] pub const Z: u32 = 0 - 1; -//~^ WARN attempt to subtract with overflow -//~| WARN this constant cannot be used +//~^ WARN this constant cannot be used pub type Foo = [i32; 0 - 1]; //~^ WARN attempt to subtract with overflow diff --git a/src/test/ui/const-eval/pub_const_err.stderr b/src/test/ui/const-eval/pub_const_err.stderr index 35228941754..fa3a79a5f17 100644 --- a/src/test/ui/const-eval/pub_const_err.stderr +++ b/src/test/ui/const-eval/pub_const_err.stderr @@ -1,8 +1,10 @@ -warning: attempt to subtract with overflow - --> $DIR/pub_const_err.rs:16:20 +warning: this constant cannot be used + --> $DIR/pub_const_err.rs:16:1 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^-----^ + | | + | attempt to subtract with overflow | note: lint level defined here --> $DIR/pub_const_err.rs:12:9 @@ -10,22 +12,14 @@ note: lint level defined here LL | #![warn(const_err)] | ^^^^^^^^^ -warning: this constant cannot be used - --> $DIR/pub_const_err.rs:16:1 - | -LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ - | | - | attempt to subtract with overflow - warning: attempt to subtract with overflow - --> $DIR/pub_const_err.rs:20:22 + --> $DIR/pub_const_err.rs:19:22 | LL | pub type Foo = [i32; 0 - 1]; | ^^^^^ warning: this array length cannot be used - --> $DIR/pub_const_err.rs:20:22 + --> $DIR/pub_const_err.rs:19:22 | LL | pub type Foo = [i32; 0 - 1]; | ^^^^^ attempt to subtract with overflow diff --git a/src/test/ui/const-eval/pub_const_err_bin.rs b/src/test/ui/const-eval/pub_const_err_bin.rs index f65da1d8674..bafa5b2f4da 100644 --- a/src/test/ui/const-eval/pub_const_err_bin.rs +++ b/src/test/ui/const-eval/pub_const_err_bin.rs @@ -12,8 +12,7 @@ #![warn(const_err)] pub const Z: u32 = 0 - 1; -//~^ WARN attempt to subtract with overflow -//~| WARN this constant cannot be used +//~^ WARN this constant cannot be used pub type Foo = [i32; 0 - 1]; //~^ WARN attempt to subtract with overflow diff --git a/src/test/ui/const-eval/pub_const_err_bin.stderr b/src/test/ui/const-eval/pub_const_err_bin.stderr index a6db2176011..73229c60d14 100644 --- a/src/test/ui/const-eval/pub_const_err_bin.stderr +++ b/src/test/ui/const-eval/pub_const_err_bin.stderr @@ -1,8 +1,10 @@ -warning: attempt to subtract with overflow - --> $DIR/pub_const_err_bin.rs:14:20 +warning: this constant cannot be used + --> $DIR/pub_const_err_bin.rs:14:1 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^-----^ + | | + | attempt to subtract with overflow | note: lint level defined here --> $DIR/pub_const_err_bin.rs:12:9 @@ -10,22 +12,14 @@ note: lint level defined here LL | #![warn(const_err)] | ^^^^^^^^^ -warning: this constant cannot be used - --> $DIR/pub_const_err_bin.rs:14:1 - | -LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ - | | - | attempt to subtract with overflow - warning: attempt to subtract with overflow - --> $DIR/pub_const_err_bin.rs:18:22 + --> $DIR/pub_const_err_bin.rs:17:22 | LL | pub type Foo = [i32; 0 - 1]; | ^^^^^ warning: this array length cannot be used - --> $DIR/pub_const_err_bin.rs:18:22 + --> $DIR/pub_const_err_bin.rs:17:22 | LL | pub type Foo = [i32; 0 - 1]; | ^^^^^ attempt to subtract with overflow diff --git a/src/test/ui/const-eval/shift_overflow.rs b/src/test/ui/const-eval/shift_overflow.rs new file mode 100644 index 00000000000..a2c6ed36d30 --- /dev/null +++ b/src/test/ui/const-eval/shift_overflow.rs @@ -0,0 +1,19 @@ +// Copyright 2018 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. + +enum Foo { + // test that we detect overflows for non-u32 discriminants + X = 1 << ((u32::max_value() as u64) + 1), //~ ERROR E0080 + Y = 42, +} + + +fn main() { +} diff --git a/src/test/ui/const-eval/shift_overflow.stderr b/src/test/ui/const-eval/shift_overflow.stderr new file mode 100644 index 00000000000..00a748249ea --- /dev/null +++ b/src/test/ui/const-eval/shift_overflow.stderr @@ -0,0 +1,9 @@ +error[E0080]: could not evaluate enum discriminant + --> $DIR/shift_overflow.rs:13:9 + | +LL | X = 1 << ((u32::max_value() as u64) + 1), //~ ERROR E0080 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift left with overflow + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/const-len-underflow-separate-spans.rs b/src/test/ui/const-len-underflow-separate-spans.rs index 20b88657674..8db1411005e 100644 --- a/src/test/ui/const-len-underflow-separate-spans.rs +++ b/src/test/ui/const-len-underflow-separate-spans.rs @@ -15,11 +15,11 @@ const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; -//~^ ERROR E0080 -//~| ERROR attempt to subtract with overflow fn main() { let a: [i8; LEN] = unimplemented!(); //~^ ERROR E0080 //~| ERROR E0080 +//~| ERROR E0080 +//~| ERROR E0080 } diff --git a/src/test/ui/const-len-underflow-separate-spans.stderr b/src/test/ui/const-len-underflow-separate-spans.stderr index 630828ef8f5..cf97a0dc555 100644 --- a/src/test/ui/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/const-len-underflow-separate-spans.stderr @@ -1,19 +1,20 @@ -error: attempt to subtract with overflow - --> $DIR/const-len-underflow-separate-spans.rs:17:20 +error[E0080]: referenced constant has errors + --> $DIR/const-len-underflow-separate-spans.rs:20:17 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ - | - = note: #[deny(const_err)] on by default + | --------- attempt to subtract with overflow +... +LL | let a: [i8; LEN] = unimplemented!(); + | ^^^ -error[E0080]: constant evaluation error - --> $DIR/const-len-underflow-separate-spans.rs:17:20 +error[E0080]: could not evaluate constant + --> $DIR/const-len-underflow-separate-spans.rs:20:17 | -LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^ attempt to subtract with overflow +LL | let a: [i8; LEN] = unimplemented!(); + | ^^^ referenced constant has errors -error[E0080]: referenced constant - --> $DIR/const-len-underflow-separate-spans.rs:22:12 +error[E0080]: referenced constant has errors + --> $DIR/const-len-underflow-separate-spans.rs:20:12 | LL | const LEN: usize = ONE - TWO; | --------- attempt to subtract with overflow @@ -22,7 +23,7 @@ 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:20:12 | LL | let a: [i8; LEN] = unimplemented!(); | ^^^^^---^ diff --git a/src/test/ui/suggestions/str-array-assignment.stderr b/src/test/ui/suggestions/str-array-assignment.stderr index 12699d8b25f..041bae4a421 100644 --- a/src/test/ui/suggestions/str-array-assignment.stderr +++ b/src/test/ui/suggestions/str-array-assignment.stderr @@ -14,7 +14,10 @@ LL | fn main() { | - expected `()` because of default return type ... LL | let u: &str = if true { s[..2] } else { s }; - | ^^^^^^ expected &str, found str + | ^^^^^^ + | | + | expected &str, found str + | help: consider borrowing here: `&s[..2]` | = note: expected type `&str` found type `str` |
