Auto merge of #53821 - oli-obk:sanity_query, r=RalfJung
Report const eval error inside the query Functional changes: We no longer warn about bad constants embedded in unused types. This relied on being able to report just a warning, not a hard error on that case, which we cannot do any more now that error reporting is consistently centralized. r? @RalfJung fixes #53561
This commit is contained in:
commit
694cf75298
148 changed files with 1133 additions and 1232 deletions
|
|
@ -11,7 +11,7 @@
|
|||
const A: &'static [i32] = &[];
|
||||
const B: i32 = (&A)[1];
|
||||
//~^ index out of bounds: the len is 0 but the index is 1
|
||||
//~| ERROR this constant cannot be used
|
||||
//~| ERROR any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
let _ = B;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/array_const_index-0.rs:12:1
|
||||
|
|
||||
LL | const B: i32 = (&A)[1];
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
const A: [i32; 0] = [];
|
||||
const B: i32 = A[1];
|
||||
//~^ index out of bounds: the len is 0 but the index is 1
|
||||
//~| ERROR this constant cannot be used
|
||||
//~| ERROR any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
let _ = B;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/array_const_index-1.rs:12:1
|
||||
|
|
||||
LL | const B: i32 = A[1];
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const FOO: [usize; 3] = [1, 2, 3];
|
|||
const BAR: usize = FOO[5]; // no error, because the error below occurs before regular const eval
|
||||
|
||||
const BLUB: [u32; FOO[4]] = [5, 6];
|
||||
//~^ ERROR could not evaluate constant expression [E0080]
|
||||
//~^ ERROR evaluation of constant value failed [E0080]
|
||||
//~| index out of bounds: the len is 3 but the index is 4
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
error: index out of bounds: the len is 3 but the index is 4
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-array-oob.rs:18:19
|
||||
|
|
||||
LL | const BLUB: [u32; FOO[4]] = [5, 6];
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
| ^^^^^^ index out of bounds: the len is 3 but the index is 4
|
||||
|
||||
error[E0080]: could not evaluate constant expression
|
||||
--> $DIR/const-array-oob.rs:18:13
|
||||
|
|
||||
LL | const BLUB: [u32; FOO[4]] = [5, 6];
|
||||
| ^^^^^^------^
|
||||
| |
|
||||
| index out of bounds: the len is 3 but the index is 4
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:13:1
|
||||
|
|
||||
LL | pub const A: i8 = -std::i8::MIN; //~ ERROR const_err
|
||||
|
|
@ -12,7 +12,7 @@ note: lint level defined here
|
|||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:14:1
|
||||
|
|
||||
LL | pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err
|
||||
|
|
@ -20,7 +20,7 @@ LL | pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err
|
|||
| |
|
||||
| attempt to add with overflow
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:15:1
|
||||
|
|
||||
LL | pub const C: u8 = 200u8 * 4; //~ ERROR const_err
|
||||
|
|
@ -28,7 +28,7 @@ LL | pub const C: u8 = 200u8 * 4; //~ ERROR const_err
|
|||
| |
|
||||
| attempt to multiply with overflow
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:16:1
|
||||
|
|
||||
LL | pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err
|
||||
|
|
@ -36,7 +36,7 @@ LL | pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err
|
|||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-early.rs:17:1
|
||||
|
|
||||
LL | pub const E: u8 = [5u8][1]; //~ ERROR const_err
|
||||
|
|
|
|||
|
|
@ -11,16 +11,13 @@
|
|||
#![deny(const_err)]
|
||||
|
||||
pub const A: i8 = -std::i8::MIN;
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR const_err
|
||||
pub const B: i8 = A;
|
||||
//~^ ERROR const_err
|
||||
//~| ERROR const_err
|
||||
pub const C: u8 = A as u8;
|
||||
//~^ ERROR const_err
|
||||
//~| ERROR const_err
|
||||
pub const D: i8 = 50 - A;
|
||||
//~^ ERROR const_err
|
||||
//~| ERROR const_err
|
||||
|
||||
fn main() {
|
||||
let _ = (A, B, C, D);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-multi.rs:13:1
|
||||
|
|
||||
LL | pub const A: i8 = -std::i8::MIN;
|
||||
|
|
@ -12,16 +12,7 @@ note: lint level defined here
|
|||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: referenced constant has errors
|
||||
--> $DIR/const-err-multi.rs:15:1
|
||||
|
|
||||
LL | pub const A: i8 = -std::i8::MIN;
|
||||
| ------------- attempt to negate with overflow
|
||||
LL | //~^ ERROR this constant cannot be used
|
||||
LL | pub const B: i8 = A;
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-multi.rs:15:1
|
||||
|
|
||||
LL | pub const B: i8 = A;
|
||||
|
|
@ -29,39 +20,21 @@ LL | pub const B: i8 = A;
|
|||
| |
|
||||
| referenced constant has errors
|
||||
|
||||
error: referenced constant has errors
|
||||
--> $DIR/const-err-multi.rs:18:1
|
||||
|
|
||||
LL | pub const A: i8 = -std::i8::MIN;
|
||||
| ------------- attempt to negate with overflow
|
||||
...
|
||||
LL | pub const C: u8 = A as u8;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-err-multi.rs:18:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-multi.rs:17:1
|
||||
|
|
||||
LL | pub const C: u8 = A as u8;
|
||||
| ^^^^^^^^^^^^^^^^^^-------^
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
||||
error: referenced constant has errors
|
||||
--> $DIR/const-err-multi.rs:21:1
|
||||
|
|
||||
LL | pub const A: i8 = -std::i8::MIN;
|
||||
| ------------- attempt to negate with overflow
|
||||
...
|
||||
LL | pub const D: i8 = 50 - A;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-err-multi.rs:21:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-err-multi.rs:19:1
|
||||
|
|
||||
LL | pub const D: i8 = 50 - A;
|
||||
| ^^^^^^^^^^^^^^^^^^------^
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -10,23 +10,17 @@
|
|||
|
||||
// compile-flags: -Zforce-overflow-checks=on
|
||||
|
||||
// these errors are not actually "const_err", they occur in codegen/consts
|
||||
// and are unconditional warnings that can't be denied or allowed
|
||||
|
||||
#![allow(exceeding_bitshifts)]
|
||||
#![allow(const_err)]
|
||||
#![warn(const_err)]
|
||||
|
||||
fn black_box<T>(_: T) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
// Make sure that the two uses get two errors.
|
||||
const FOO: u8 = [5u8][1];
|
||||
//~^ ERROR constant evaluation error
|
||||
//~| index out of bounds: the len is 1 but the index is 1
|
||||
//~^ WARN any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
black_box((FOO, FOO));
|
||||
//~^ ERROR referenced constant has errors
|
||||
//~| ERROR could not evaluate constant
|
||||
//~^ ERROR erroneous constant used
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +1,23 @@
|
|||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/const-err.rs:29:15
|
||||
|
|
||||
LL | const FOO: u8 = [5u8][1];
|
||||
| -------- index out of bounds: the len is 1 but the index is 1
|
||||
...
|
||||
LL | black_box((FOO, FOO));
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error[E0080]: could not evaluate constant
|
||||
--> $DIR/const-err.rs:29:15
|
||||
|
|
||||
LL | black_box((FOO, FOO));
|
||||
| ^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
error[E0080]: constant evaluation error
|
||||
--> $DIR/const-err.rs:24:1
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/const-err.rs:20:1
|
||||
|
|
||||
LL | const FOO: u8 = [5u8][1];
|
||||
| ^^^^^^^^^^^^^^^^--------^
|
||||
| |
|
||||
| index out of bounds: the len is 1 but the index is 1
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/const-err.rs:14:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/const-err.rs:24:15
|
||||
|
|
||||
LL | black_box((FOO, FOO));
|
||||
| ^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ union Foo {
|
|||
|
||||
enum Bar {
|
||||
Boo = [unsafe { Foo { b: () }.a }; 4][3],
|
||||
//~^ ERROR could not evaluate enum discriminant
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: could not evaluate enum discriminant
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-err4.rs:18:11
|
||||
|
|
||||
LL | Boo = [unsafe { Foo { b: () }.a }; 4][3],
|
||||
|
|
|
|||
|
|
@ -13,10 +13,9 @@
|
|||
const X: u32 = 5;
|
||||
const Y: u32 = 6;
|
||||
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
//~^ WARN this constant cannot be used
|
||||
//~^ WARN any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
println!("{}", FOO);
|
||||
//~^ ERROR
|
||||
//~| ERROR
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: this constant cannot be used
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/conditional_array_execution.rs:15:1
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
|
|
@ -12,21 +12,12 @@ note: lint level defined here
|
|||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
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
|
||||
...
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
error[E0080]: could not evaluate constant pattern
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/const-eval-overflow-2.rs:25:9
|
||||
|
|
||||
LL | const NEG_NEG_128: i8 = -NEG_128;
|
||||
| -------- attempt to negate with overflow
|
||||
...
|
||||
LL | NEG_NEG_128 => println!("A"),
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
error: attempt to add with overflow
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-eval-overflow-3.rs:30:11
|
||||
|
|
||||
LL | = [0; (i8::MAX + 1) as usize];
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
| ^^^^^^^^^^^^^ attempt to add with overflow
|
||||
|
||||
error[E0080]: could not evaluate repeat length
|
||||
--> $DIR/const-eval-overflow-3.rs:30:11
|
||||
|
|
||||
LL | = [0; (i8::MAX + 1) as usize];
|
||||
| -------------^^^^^^^^^
|
||||
| |
|
||||
| attempt to add with overflow
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -21,8 +21,7 @@ use std::{u8, u16, u32, u64, usize};
|
|||
|
||||
const A_I8_T
|
||||
: [u32; (i8::MAX as i8 + 1i8) as usize]
|
||||
//~^ ERROR attempt to add with overflow
|
||||
//~| ERROR could not evaluate constant expression
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
= [0; (i8::MAX as usize) + 1];
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
error: attempt to add with overflow
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-eval-overflow-4.rs:23:13
|
||||
|
|
||||
LL | : [u32; (i8::MAX as i8 + 1i8) as usize]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ attempt to add with overflow
|
||||
|
||||
error[E0080]: could not evaluate constant expression
|
||||
--> $DIR/const-eval-overflow-4.rs:23:7
|
||||
|
|
||||
LL | : [u32; (i8::MAX as i8 + 1i8) as usize]
|
||||
| ^^^^^^---------------------^^^^^^^^^^
|
||||
| |
|
||||
| attempt to add with overflow
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -21,48 +21,40 @@ use std::fmt;
|
|||
use std::{i8, i16, i32, i64, isize};
|
||||
use std::{u8, u16, u32, u64, usize};
|
||||
|
||||
const VALS_I8: (i8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i8::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_I16: (i16,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i16::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_I32: (i32,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i32::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_I64: (i64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i64::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_U8: (u8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
u8::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_U16: (u16,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
|
||||
u16::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_U32: (u32,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
|
||||
u32::MIN - 1,
|
||||
);
|
||||
|
||||
const VALS_U64: (u64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
u64::MIN - 1,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:24:1
|
||||
|
|
||||
LL | / const VALS_I8: (i8,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i8::MIN - 1,
|
||||
| | ----------- attempt to subtract with overflow
|
||||
|
|
@ -15,75 +14,68 @@ note: lint level defined here
|
|||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:30:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:29:1
|
||||
|
|
||||
LL | / const VALS_I16: (i16,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i16::MIN - 1,
|
||||
| | ------------ attempt to subtract with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:36:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:34:1
|
||||
|
|
||||
LL | / const VALS_I32: (i32,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i32::MIN - 1,
|
||||
| | ------------ attempt to subtract with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:42:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:39:1
|
||||
|
|
||||
LL | / const VALS_I64: (i64,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i64::MIN - 1,
|
||||
| | ------------ attempt to subtract with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:48:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:44:1
|
||||
|
|
||||
LL | / const VALS_U8: (u8,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | u8::MIN - 1,
|
||||
| | ----------- attempt to subtract with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:54:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:49:1
|
||||
|
|
||||
LL | / const VALS_U16: (u16,) = (
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
|
||||
LL | | u16::MIN - 1,
|
||||
| | ------------ attempt to subtract with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:59:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:53:1
|
||||
|
|
||||
LL | / const VALS_U32: (u32,) = (
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
|
||||
LL | | u32::MIN - 1,
|
||||
| | ------------ attempt to subtract with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2.rs:64:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2.rs:57:1
|
||||
|
|
||||
LL | / const VALS_U64: (u64,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | u64::MIN - 1,
|
||||
| | ------------ attempt to subtract with overflow
|
||||
|
|
|
|||
|
|
@ -21,48 +21,40 @@ use std::fmt;
|
|||
use std::{i8, i16, i32, i64, isize};
|
||||
use std::{u8, u16, u32, u64, usize};
|
||||
|
||||
const VALS_I8: (i8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i8::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_I16: (i16,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i16::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_I32: (i32,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i32::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_I64: (i64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i64::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_U8: (u8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
u8::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_U16: (u16,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
|
||||
u16::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_U32: (u32,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
|
||||
u32::MAX + 1,
|
||||
);
|
||||
|
||||
const VALS_U64: (u64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
u64::MAX + 1,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:24:1
|
||||
|
|
||||
LL | / const VALS_I8: (i8,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i8::MAX + 1,
|
||||
| | ----------- attempt to add with overflow
|
||||
|
|
@ -15,75 +14,68 @@ note: lint level defined here
|
|||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:30:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:29:1
|
||||
|
|
||||
LL | / const VALS_I16: (i16,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i16::MAX + 1,
|
||||
| | ------------ attempt to add with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:36:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:34:1
|
||||
|
|
||||
LL | / const VALS_I32: (i32,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i32::MAX + 1,
|
||||
| | ------------ attempt to add with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:42:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:39:1
|
||||
|
|
||||
LL | / const VALS_I64: (i64,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i64::MAX + 1,
|
||||
| | ------------ attempt to add with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:48:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:44:1
|
||||
|
|
||||
LL | / const VALS_U8: (u8,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | u8::MAX + 1,
|
||||
| | ----------- attempt to add with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:54:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:49:1
|
||||
|
|
||||
LL | / const VALS_U16: (u16,) = (
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
|
||||
LL | | u16::MAX + 1,
|
||||
| | ------------ attempt to add with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:59:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:53:1
|
||||
|
|
||||
LL | / const VALS_U32: (u32,) = (
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
|
||||
LL | | u32::MAX + 1,
|
||||
| | ------------ attempt to add with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2b.rs:64:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2b.rs:57:1
|
||||
|
|
||||
LL | / const VALS_U64: (u64,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | u64::MAX + 1,
|
||||
| | ------------ attempt to add with overflow
|
||||
|
|
|
|||
|
|
@ -21,48 +21,40 @@ use std::fmt;
|
|||
use std::{i8, i16, i32, i64, isize};
|
||||
use std::{u8, u16, u32, u64, usize};
|
||||
|
||||
const VALS_I8: (i8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i8::MIN * 2,
|
||||
);
|
||||
|
||||
const VALS_I16: (i16,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i16::MIN * 2,
|
||||
);
|
||||
|
||||
const VALS_I32: (i32,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i32::MIN * 2,
|
||||
);
|
||||
|
||||
const VALS_I64: (i64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
i64::MIN * 2,
|
||||
);
|
||||
|
||||
const VALS_U8: (u8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
u8::MAX * 2,
|
||||
);
|
||||
|
||||
const VALS_U16: (u16,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
|
||||
u16::MAX * 2,
|
||||
);
|
||||
|
||||
const VALS_U32: (u32,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
|
||||
u32::MAX * 2,
|
||||
);
|
||||
|
||||
const VALS_U64: (u64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
|
||||
(
|
||||
u64::MAX * 2,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:24:1
|
||||
|
|
||||
LL | / const VALS_I8: (i8,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i8::MIN * 2,
|
||||
| | ----------- attempt to multiply with overflow
|
||||
|
|
@ -15,75 +14,68 @@ note: lint level defined here
|
|||
LL | #![deny(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:30:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:29:1
|
||||
|
|
||||
LL | / const VALS_I16: (i16,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i16::MIN * 2,
|
||||
| | ------------ attempt to multiply with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:36:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:34:1
|
||||
|
|
||||
LL | / const VALS_I32: (i32,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i32::MIN * 2,
|
||||
| | ------------ attempt to multiply with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:42:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:39:1
|
||||
|
|
||||
LL | / const VALS_I64: (i64,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | i64::MIN * 2,
|
||||
| | ------------ attempt to multiply with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:48:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:44:1
|
||||
|
|
||||
LL | / const VALS_U8: (u8,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | u8::MAX * 2,
|
||||
| | ----------- attempt to multiply with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:54:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:49:1
|
||||
|
|
||||
LL | / const VALS_U16: (u16,) = (
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error
|
||||
LL | | u16::MAX * 2,
|
||||
| | ------------ attempt to multiply with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:59:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:53:1
|
||||
|
|
||||
LL | / const VALS_U32: (u32,) = (
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error
|
||||
LL | | u32::MAX * 2,
|
||||
| | ------------ attempt to multiply with overflow
|
||||
LL | | );
|
||||
| |_______^
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-eval-overflow2c.rs:64:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-eval-overflow2c.rs:57:1
|
||||
|
|
||||
LL | / const VALS_U64: (u64,) =
|
||||
LL | | //~^ ERROR this constant cannot be used
|
||||
LL | / const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error
|
||||
LL | | (
|
||||
LL | | u64::MAX * 2,
|
||||
| | ------------ attempt to multiply with overflow
|
||||
|
|
|
|||
|
|
@ -22,89 +22,89 @@ union Nonsense {
|
|||
|
||||
fn main() {
|
||||
const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:24:5
|
||||
|
|
||||
LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }.u };
|
||||
|
|
@ -6,7 +6,7 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 }
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:27:5
|
||||
|
|
||||
LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 };
|
||||
|
|
@ -16,7 +16,7 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_
|
|||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:30:5
|
||||
|
|
||||
LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 };
|
||||
|
|
@ -24,7 +24,7 @@ LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uin
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:33:5
|
||||
|
|
||||
LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 };
|
||||
|
|
@ -32,7 +32,7 @@ LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uin
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:36:5
|
||||
|
|
||||
LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 };
|
||||
|
|
@ -40,13 +40,13 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:39:5
|
||||
|
|
||||
LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:42:5
|
||||
|
|
||||
LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 };
|
||||
|
|
@ -54,7 +54,7 @@ LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:45:5
|
||||
|
|
||||
LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 };
|
||||
|
|
@ -62,7 +62,7 @@ LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:48:5
|
||||
|
|
||||
LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 };
|
||||
|
|
@ -70,7 +70,7 @@ LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:51:5
|
||||
|
|
||||
LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 };
|
||||
|
|
@ -78,13 +78,13 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:54:5
|
||||
|
|
||||
LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:57:5
|
||||
|
|
||||
LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 };
|
||||
|
|
@ -92,7 +92,7 @@ LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.flo
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:60:5
|
||||
|
|
||||
LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 };
|
||||
|
|
@ -100,7 +100,7 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:63:5
|
||||
|
|
||||
LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey };
|
||||
|
|
@ -108,7 +108,7 @@ LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.t
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:66:5
|
||||
|
|
||||
LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character };
|
||||
|
|
@ -116,7 +116,7 @@ LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.c
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:69:5
|
||||
|
|
||||
LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
|
||||
|
|
@ -124,7 +124,7 @@ LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 };
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:72:5
|
||||
|
|
||||
LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 };
|
||||
|
|
@ -132,7 +132,7 @@ LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:75:5
|
||||
|
|
||||
LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 };
|
||||
|
|
@ -140,7 +140,7 @@ LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:78:5
|
||||
|
|
||||
LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 };
|
||||
|
|
@ -148,7 +148,7 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:81:5
|
||||
|
|
||||
LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 };
|
||||
|
|
@ -156,7 +156,7 @@ LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_12
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:84:5
|
||||
|
|
||||
LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
|
||||
|
|
@ -164,7 +164,7 @@ LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 };
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:87:5
|
||||
|
|
||||
LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
|
||||
|
|
@ -172,7 +172,7 @@ LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 };
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:90:5
|
||||
|
|
||||
LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
|
||||
|
|
@ -180,7 +180,7 @@ LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 };
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:93:5
|
||||
|
|
||||
LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
|
||||
|
|
@ -188,7 +188,7 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:96:5
|
||||
|
|
||||
LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 };
|
||||
|
|
@ -196,7 +196,7 @@ LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:99:5
|
||||
|
|
||||
LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 };
|
||||
|
|
@ -204,7 +204,7 @@ LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:102:5
|
||||
|
|
||||
LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 };
|
||||
|
|
@ -212,7 +212,7 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:105:5
|
||||
|
|
||||
LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey };
|
||||
|
|
@ -220,7 +220,7 @@ LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_
|
|||
| |
|
||||
| a raw memory access tried to access part of a pointer value as raw bytes
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-pointer-values-in-various-types.rs:108:5
|
||||
|
|
||||
LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character };
|
||||
|
|
|
|||
|
|
@ -9,14 +9,13 @@
|
|||
// except according to those terms.
|
||||
|
||||
#![feature(const_panic)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
fn main() {}
|
||||
pub const Z: () = panic!("cheese");
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Z: () = panic!("cheese");
|
||||
//~^ ERROR this constant cannot be used
|
||||
pub const Y: () = unreachable!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Y: () = unreachable!();
|
||||
//~^ ERROR this constant cannot be used
|
||||
|
||||
const X: () = unimplemented!();
|
||||
//~^ ERROR this constant cannot be used
|
||||
pub const X: () = unimplemented!();
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
error: this constant cannot be used
|
||||
--> $DIR/const_panic.rs:15:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:14:1
|
||||
|
|
||||
LL | const Z: () = panic!("cheese");
|
||||
| ^^^^^^^^^^^^^^----------------^
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:15:15
|
||||
LL | pub const Z: () = panic!("cheese");
|
||||
| ^^^^^^^^^^^^^^^^^^----------------^
|
||||
| |
|
||||
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:14:19
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
= 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: this constant cannot be used
|
||||
--> $DIR/const_panic.rs:18:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:17:1
|
||||
|
|
||||
LL | const Y: () = unreachable!();
|
||||
| ^^^^^^^^^^^^^^--------------^
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:18:15
|
||||
LL | pub const Y: () = unreachable!();
|
||||
| ^^^^^^^^^^^^^^^^^^--------------^
|
||||
| |
|
||||
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:17:19
|
||||
|
|
||||
= 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: this constant cannot be used
|
||||
--> $DIR/const_panic.rs:21:1
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic.rs:20:1
|
||||
|
|
||||
LL | const X: () = unimplemented!();
|
||||
| ^^^^^^^^^^^^^^----------------^
|
||||
| |
|
||||
| the evaluated program panicked at 'not yet implemented', $DIR/const_panic.rs:21:15
|
||||
LL | pub const X: () = unimplemented!();
|
||||
| ^^^^^^^^^^^^^^^^^^----------------^
|
||||
| |
|
||||
| the evaluated program panicked at 'not yet implemented', $DIR/const_panic.rs:20:19
|
||||
|
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@
|
|||
#![feature(const_panic)]
|
||||
|
||||
const Z: () = panic!("cheese");
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Y: () = unreachable!();
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const X: () = unimplemented!();
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore.rs:15:1
|
||||
|
|
||||
LL | const Z: () = panic!("cheese");
|
||||
|
|
@ -9,7 +9,7 @@ LL | const Z: () = panic!("cheese");
|
|||
= note: #[deny(const_err)] on by default
|
||||
= 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: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore.rs:18:1
|
||||
|
|
||||
LL | const Y: () = unreachable!();
|
||||
|
|
@ -19,7 +19,7 @@ LL | const Y: () = unreachable!();
|
|||
|
|
||||
= 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: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore.rs:21:1
|
||||
|
|
||||
LL | const X: () = unimplemented!();
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
use core::panic::PanicInfo;
|
||||
|
||||
const Z: () = panic!("cheese");
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const Y: () = unreachable!();
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
const X: () = unimplemented!();
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
#[lang = "eh_personality"]
|
||||
fn eh() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore_main.rs:19:1
|
||||
|
|
||||
LL | const Z: () = panic!("cheese");
|
||||
|
|
@ -9,7 +9,7 @@ LL | const Z: () = panic!("cheese");
|
|||
= note: #[deny(const_err)] on by default
|
||||
= 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: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore_main.rs:22:1
|
||||
|
|
||||
LL | const Y: () = unreachable!();
|
||||
|
|
@ -19,7 +19,7 @@ LL | const Y: () = unreachable!();
|
|||
|
|
||||
= 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: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_panic_libcore_main.rs:25:1
|
||||
|
|
||||
LL | const X: () = unimplemented!();
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@
|
|||
fn main() {}
|
||||
|
||||
// unconst and bad, will thus error in miri
|
||||
const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR cannot be used
|
||||
const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR any use of this value will cause
|
||||
// unconst and fine
|
||||
const X2: bool = 42 as *const i32 == 43 as *const i32;
|
||||
// unconst and fine
|
||||
const Y: usize = 42usize as *const i32 as usize + 1;
|
||||
// unconst and bad, will thus error in miri
|
||||
const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR cannot be used
|
||||
const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR any use of this value will cause
|
||||
// unconst and fine
|
||||
const Z: i32 = unsafe { *(&1 as *const i32) };
|
||||
// unconst and bad, will thus error in miri
|
||||
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR cannot be used
|
||||
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR cannot be used
|
||||
const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause
|
||||
const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:16:1
|
||||
|
|
||||
LL | const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR cannot be used
|
||||
LL | const X: bool = &1 as *const i32 == &2 as *const i32; //~ ERROR any use of this value will cause
|
||||
| ^^^^^^^^^^^^^^^^------------------------------------^
|
||||
| |
|
||||
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:22:1
|
||||
|
|
||||
LL | const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR cannot be used
|
||||
LL | const Y2: usize = &1 as *const i32 as usize + 1; //~ ERROR any use of this value will cause
|
||||
| ^^^^^^^^^^^^^^^^^^-----------------------------^
|
||||
| |
|
||||
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:26:1
|
||||
|
|
||||
LL | const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR cannot be used
|
||||
LL | const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^
|
||||
| |
|
||||
| a memory access tried to interpret some bytes as a pointer
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const_raw_ptr_ops.rs:27:1
|
||||
|
|
||||
LL | const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR cannot be used
|
||||
LL | const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^
|
||||
| |
|
||||
| a memory access tried to interpret some bytes as a pointer
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this static likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/double_check2.rs:25:1
|
||||
|
|
||||
LL | / static FOO: (&Foo, &Bar) = unsafe {( //~ undefined behavior
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ fn main() {
|
|||
// The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
|
||||
let _ = [(); {
|
||||
//~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
//~| ERROR could not evaluate repeat length
|
||||
let mut n = 113383; // #20 in https://oeis.org/A006884
|
||||
while n != 0 { //~ ERROR constant contains unimplemented expression type
|
||||
n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
}
|
||||
n
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/infinite_loop.rs:20:9
|
||||
--> $DIR/infinite_loop.rs:19:9
|
||||
|
|
||||
LL | / while n != 0 { //~ ERROR constant contains unimplemented expression type
|
||||
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
LL | | //~^ ERROR evaluation of constant value failed
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
||||
|
|
@ -12,28 +13,18 @@ warning: Constant evaluating a complex constant, this might take some time
|
|||
LL | let _ = [(); {
|
||||
| __________________^
|
||||
LL | | //~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
LL | | //~| ERROR could not evaluate repeat length
|
||||
LL | | let mut n = 113383; // #20 in https://oeis.org/A006884
|
||||
LL | | while n != 0 { //~ ERROR constant contains unimplemented expression type
|
||||
... |
|
||||
LL | | n
|
||||
LL | | }];
|
||||
| |_____^
|
||||
|
||||
error[E0080]: could not evaluate repeat length
|
||||
--> $DIR/infinite_loop.rs:16:18
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/infinite_loop.rs:20:20
|
||||
|
|
||||
LL | let _ = [(); {
|
||||
| __________________^
|
||||
LL | | //~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
LL | | //~| ERROR could not evaluate repeat length
|
||||
LL | | let mut n = 113383; // #20 in https://oeis.org/A006884
|
||||
LL | | while n != 0 { //~ ERROR constant contains unimplemented expression type
|
||||
LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
| | ---------- duplicate interpreter state observed here, const evaluation will never terminate
|
||||
LL | | }
|
||||
LL | | n
|
||||
LL | | }];
|
||||
| |_____^
|
||||
LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
||||
| ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,10 @@ const fn foo(x: u32) -> u32 {
|
|||
|
||||
fn main() {
|
||||
const X: u32 = 0-1;
|
||||
//~^ WARN this constant cannot be used
|
||||
//~^ WARN any use of this value will cause
|
||||
const Y: u32 = foo(0-1);
|
||||
//~^ WARN this constant cannot be used
|
||||
//~^ WARN any use of this value will cause
|
||||
println!("{} {}", X, Y);
|
||||
//~^ ERROR erroneous constant used
|
||||
//~| ERROR erroneous constant used
|
||||
//~| ERROR E0080
|
||||
//~| ERROR E0080
|
||||
//~^ ERROR evaluation of constant expression failed
|
||||
//~| ERROR evaluation of constant expression failed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: this constant cannot be used
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/issue-43197.rs:18:5
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
|
|
@ -12,7 +12,7 @@ note: lint level defined here
|
|||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/issue-43197.rs:20:5
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
|
|
@ -20,36 +20,18 @@ LL | const Y: u32 = foo(0-1);
|
|||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:22: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
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-43197.rs:22:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-43197.rs:22:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-43197.rs:22:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -33,6 +33,5 @@ impl Foo for u16 {
|
|||
|
||||
fn main() {
|
||||
println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||
//~^ ERROR erroneous constant used
|
||||
//~| ERROR E0080
|
||||
//~^ ERROR E0080
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,9 @@
|
|||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-44578.rs:35:20
|
||||
|
|
||||
LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize];
|
||||
| ------------------------------------ index out of bounds: the len is 1 but the index is 1
|
||||
...
|
||||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-44578.rs:35:20
|
||||
|
|
||||
LL | println!("{}", <Bar<u16, u8> as Foo>::AMT);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -19,12 +19,11 @@ trait Foo<T> {
|
|||
struct A<T>(T);
|
||||
|
||||
impl<T: C> Foo<T> for A<T> {
|
||||
const BAR: usize = [5, 6, 7][T::BOO];
|
||||
const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error
|
||||
}
|
||||
|
||||
fn foo<T: C>() -> &'static usize {
|
||||
&<A<T> as Foo<T>>::BAR //~ ERROR erroneous constant used
|
||||
//~| ERROR E0080
|
||||
&<A<T> as Foo<T>>::BAR //~ ERROR E0080
|
||||
}
|
||||
|
||||
impl C for () {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-50814-2.rs:26:5
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/issue-50814-2.rs:22:5
|
||||
|
|
||||
LL | const BAR: usize = [5, 6, 7][T::BOO];
|
||||
| ----------------- index out of bounds: the len is 3 but the index is 42
|
||||
...
|
||||
LL | &<A<T> as Foo<T>>::BAR //~ ERROR erroneous constant used
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error
|
||||
| ^^^^^^^^^^^^^^^^^^^-----------------^
|
||||
| |
|
||||
| index out of bounds: the len is 3 but the index is 42
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-50814-2.rs:26:5
|
||||
|
|
||||
LL | &<A<T> as Foo<T>>::BAR //~ ERROR erroneous constant used
|
||||
LL | &<A<T> as Foo<T>>::BAR //~ ERROR E0080
|
||||
| ^---------------------
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
|
|
|||
|
|
@ -20,12 +20,11 @@ impl Unsigned for U8 {
|
|||
struct Sum<A,B>(A,B);
|
||||
|
||||
impl<A: Unsigned, B: Unsigned> Unsigned for Sum<A,B> {
|
||||
const MAX: u8 = A::MAX + B::MAX;
|
||||
const MAX: u8 = A::MAX + B::MAX; //~ ERROR any use of this value will cause an error
|
||||
}
|
||||
|
||||
fn foo<T>(_: T) -> &'static u8 {
|
||||
&Sum::<U8,U8>::MAX //~ ERROR erroneous constant used
|
||||
//~| ERROR E0080
|
||||
&Sum::<U8,U8>::MAX //~ ERROR E0080
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/issue-50814.rs:27:5
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/issue-50814.rs:23:5
|
||||
|
|
||||
LL | const MAX: u8 = A::MAX + B::MAX;
|
||||
| --------------- attempt to add with overflow
|
||||
...
|
||||
LL | &Sum::<U8,U8>::MAX //~ ERROR erroneous constant used
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
LL | const MAX: u8 = A::MAX + B::MAX; //~ ERROR any use of this value will cause an error
|
||||
| ^^^^^^^^^^^^^^^^---------------^
|
||||
| |
|
||||
| attempt to add with overflow
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
error[E0080]: evaluation of constant expression failed
|
||||
--> $DIR/issue-50814.rs:27:5
|
||||
|
|
||||
LL | &Sum::<U8,U8>::MAX //~ ERROR erroneous constant used
|
||||
LL | &Sum::<U8,U8>::MAX //~ ERROR E0080
|
||||
| ^-----------------
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@
|
|||
|
||||
fn main() {
|
||||
[(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@ error[E0019]: constant contains unimplemented expression type
|
|||
LL | [(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/issue-52442.rs:12:11
|
||||
|
|
||||
LL | [(); { &loop { break } as *const _ as usize } ]; //~ ERROR unimplemented expression type
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
For more information about this error, try `rustc --explain E0019`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0019, E0080.
|
||||
For more information about an error, try `rustc --explain E0019`.
|
||||
|
|
|
|||
|
|
@ -13,11 +13,10 @@
|
|||
fn main() {
|
||||
let _ = [(); {
|
||||
//~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
//~| ERROR could not evaluate repeat length
|
||||
let mut x = &0;
|
||||
let mut n = 0;
|
||||
while n < 5 { //~ ERROR constant contains unimplemented expression type
|
||||
n = (n + 1) % 5;
|
||||
n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
|
||||
x = &0; // Materialize a new AllocId
|
||||
}
|
||||
0
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0019]: constant contains unimplemented expression type
|
||||
--> $DIR/issue-52475.rs:19:9
|
||||
--> $DIR/issue-52475.rs:18:9
|
||||
|
|
||||
LL | / while n < 5 { //~ ERROR constant contains unimplemented expression type
|
||||
LL | | n = (n + 1) % 5;
|
||||
LL | | n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
|
||||
LL | | x = &0; // Materialize a new AllocId
|
||||
LL | | }
|
||||
| |_________^
|
||||
|
|
@ -13,28 +13,18 @@ warning: Constant evaluating a complex constant, this might take some time
|
|||
LL | let _ = [(); {
|
||||
| __________________^
|
||||
LL | | //~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
LL | | //~| ERROR could not evaluate repeat length
|
||||
LL | | let mut x = &0;
|
||||
LL | | let mut n = 0;
|
||||
... |
|
||||
LL | | 0
|
||||
LL | | }];
|
||||
| |_____^
|
||||
|
||||
error[E0080]: could not evaluate repeat length
|
||||
--> $DIR/issue-52475.rs:14:18
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/issue-52475.rs:19:17
|
||||
|
|
||||
LL | let _ = [(); {
|
||||
| __________________^
|
||||
LL | | //~^ WARNING Constant evaluating a complex constant, this might take some time
|
||||
LL | | //~| ERROR could not evaluate repeat length
|
||||
LL | | let mut x = &0;
|
||||
... |
|
||||
LL | | n = (n + 1) % 5;
|
||||
| | ----------- duplicate interpreter state observed here, const evaluation will never terminate
|
||||
... |
|
||||
LL | | 0
|
||||
LL | | }];
|
||||
| |_____^
|
||||
LL | n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
|
||||
| ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@ fn main() {
|
|||
// Make sure match uses the usual pointer comparison code path -- i.e., it should complain
|
||||
// that pointer comparison is disallowed, not that parts of a pointer are accessed as raw
|
||||
// bytes.
|
||||
let _: [u8; 0] = [4; { //~ ERROR could not evaluate repeat length
|
||||
let _: [u8; 0] = [4; {
|
||||
match &1 as *const i32 as usize { //~ ERROR casting pointers to integers in constants
|
||||
0 => 42, //~ ERROR constant contains unimplemented expression type
|
||||
//~^ NOTE "pointer arithmetic or comparison" needs an rfc before being allowed
|
||||
//~| ERROR evaluation of constant value failed
|
||||
n => n,
|
||||
}
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -12,19 +12,11 @@ error[E0019]: constant contains unimplemented expression type
|
|||
LL | 0 => 42, //~ ERROR constant contains unimplemented expression type
|
||||
| ^
|
||||
|
||||
error[E0080]: could not evaluate repeat length
|
||||
--> $DIR/match-test-ptr-null.rs:15:26
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/match-test-ptr-null.rs:17:13
|
||||
|
|
||||
LL | let _: [u8; 0] = [4; { //~ ERROR could not evaluate repeat length
|
||||
| __________________________^
|
||||
LL | | match &1 as *const i32 as usize { //~ ERROR casting pointers to integers in constants
|
||||
LL | | 0 => 42, //~ ERROR constant contains unimplemented expression type
|
||||
| | - "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
LL | | //~^ NOTE "pointer arithmetic or comparison" needs an rfc before being allowed
|
||||
LL | | n => n,
|
||||
LL | | }
|
||||
LL | | }];
|
||||
| |_____^
|
||||
LL | 0 => 42, //~ ERROR constant contains unimplemented expression type
|
||||
| ^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#![feature(const_fn, const_fn_union)]
|
||||
|
||||
#![deny(const_err)]
|
||||
#![allow(const_err)]
|
||||
|
||||
union Bar {
|
||||
a: &'static u8,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/promoted_const_fn_fail_deny_const_err.rs:31:27
|
||||
|
|
||||
LL | let x: &'static u8 = &(bar() + 1);
|
||||
| ----------- ^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
| |
|
||||
| type annotation requires that borrow lasts for `'static`
|
||||
...
|
||||
LL | }
|
||||
| - temporary value is freed at the end of this statement
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0716`.
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
// 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.
|
||||
|
||||
#![feature(const_fn, const_fn_union)]
|
||||
|
||||
#![deny(const_err)]
|
||||
|
||||
union Bar {
|
||||
a: &'static u8,
|
||||
b: usize,
|
||||
}
|
||||
|
||||
const fn bar() -> u8 {
|
||||
unsafe {
|
||||
// This will error as long as this test is run on a system whose
|
||||
// pointers need more than 8 bits.
|
||||
Bar { a: &42 }.b as u8
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// This will compile, but then hard-abort at runtime.
|
||||
// FIXME(oli-obk): this should instead panic (not hard-abort) at runtime.
|
||||
let x: &'static u8 = &(bar() + 1);
|
||||
let y = *x;
|
||||
unreachable!();
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
--> $DIR/promoted_const_fn_fail_deny_const_err.rs:31:27
|
||||
|
|
||||
LL | let x: &'static u8 = &(bar() + 1);
|
||||
| ^^^^^^^^^^^ temporary value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - temporary value only lives until here
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
@ -46,3 +46,15 @@ warning: this expression will panic at runtime
|
|||
LL | let _x = 1/(false as u32);
|
||||
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
|
||||
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:24:20
|
||||
|
|
||||
LL | println!("{}", 1/(false as u32));
|
||||
| ^^^^^^^^^^^^^^^^ attempt to divide by zero
|
||||
|
||||
warning: reaching this expression at runtime will panic or abort
|
||||
--> $DIR/promoted_errors.rs:19:20
|
||||
|
|
||||
LL | println!("{}", 1/(1-1));
|
||||
| ^^^^^^^ attempt to divide by zero
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
#![crate_type = "lib"]
|
||||
|
||||
pub const Z: u32 = 0 - 1;
|
||||
//~^ WARN this constant cannot be used
|
||||
//~^ WARN any use of this value will cause an error
|
||||
|
||||
pub type Foo = [i32; 0 - 1];
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this array length cannot be used
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: this constant cannot be used
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/pub_const_err.rs:16:1
|
||||
|
|
||||
LL | pub const Z: u32 = 0 - 1;
|
||||
|
|
@ -12,15 +12,3 @@ note: lint level defined here
|
|||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: attempt to subtract with overflow
|
||||
--> $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:19:22
|
||||
|
|
||||
LL | pub type Foo = [i32; 0 - 1];
|
||||
| ^^^^^ attempt to subtract with overflow
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@
|
|||
#![warn(const_err)]
|
||||
|
||||
pub const Z: u32 = 0 - 1;
|
||||
//~^ WARN this constant cannot be used
|
||||
//~^ WARN any use of this value will cause an error
|
||||
|
||||
pub type Foo = [i32; 0 - 1];
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this array length cannot be used
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
warning: this constant cannot be used
|
||||
warning: any use of this value will cause an error
|
||||
--> $DIR/pub_const_err_bin.rs:14:1
|
||||
|
|
||||
LL | pub const Z: u32 = 0 - 1;
|
||||
|
|
@ -12,15 +12,3 @@ note: lint level defined here
|
|||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: attempt to subtract with overflow
|
||||
--> $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:17:22
|
||||
|
|
||||
LL | pub type Foo = [i32; 0 - 1];
|
||||
| ^^^^^ attempt to subtract with overflow
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
let n: Int = 40;
|
||||
match n {
|
||||
0..=10 => {},
|
||||
10..=BAR => {}, //~ ERROR lower range bound must be less than or equal to upper
|
||||
10..=BAR => {}, //~ ERROR could not evaluate constant pattern
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
@ -30,4 +30,4 @@ type Int = u64;
|
|||
#[cfg(target_pointer_width="32")]
|
||||
type Int = u32;
|
||||
|
||||
const BAR: Int = unsafe { Foo { r: &42 }.f };
|
||||
const BAR: Int = unsafe { Foo { r: &42 }.f }; //~ ERROR it is undefined behavior to use this value
|
||||
|
|
|
|||
|
|
@ -1,9 +1,17 @@
|
|||
error[E0030]: lower range bound must be less than or equal to upper
|
||||
--> $DIR/ref_to_int_match.rs:17:9
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ref_to_int_match.rs:33:1
|
||||
|
|
||||
LL | 10..=BAR => {}, //~ ERROR lower range bound must be less than or equal to upper
|
||||
| ^^ lower bound larger than upper bound
|
||||
LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; //~ ERROR it is undefined behavior to use this value
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain bits
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error: aborting due to previous error
|
||||
error: could not evaluate constant pattern
|
||||
--> $DIR/ref_to_int_match.rs:17:14
|
||||
|
|
||||
LL | 10..=BAR => {}, //~ ERROR could not evaluate constant pattern
|
||||
| ^^^
|
||||
|
||||
For more information about this error, try `rustc --explain E0030`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: could not evaluate enum discriminant
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/shift_overflow.rs:13:9
|
||||
|
|
||||
LL | X = 1 << ((u32::max_value() as u64) + 1), //~ ERROR E0080
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@
|
|||
use std::mem;
|
||||
|
||||
static FOO: bool = unsafe { mem::transmute(3u8) };
|
||||
//~^ ERROR this static likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this static likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/transmute-const.rs:15:1
|
||||
|
|
||||
LL | static FOO: bool = unsafe { mem::transmute(3u8) };
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ union TransmuteEnum {
|
|||
|
||||
// A pointer is guaranteed non-null
|
||||
const BAD_ENUM: Enum = unsafe { TransmuteEnum { a: &1 }.b };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR is undefined behavior
|
||||
|
||||
// Invalid enum discriminant
|
||||
#[repr(usize)]
|
||||
|
|
@ -33,7 +33,7 @@ union TransmuteEnum2 {
|
|||
b: Enum2,
|
||||
}
|
||||
const BAD_ENUM2 : Enum2 = unsafe { TransmuteEnum2 { a: 0 }.b };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR is undefined behavior
|
||||
|
||||
// Invalid enum field content (mostly to test printing of apths for enum tuple
|
||||
// variants and tuples).
|
||||
|
|
@ -43,7 +43,7 @@ union TransmuteChar {
|
|||
}
|
||||
// Need to create something which does not clash with enum layout optimizations.
|
||||
const BAD_ENUM_CHAR : Option<(char, char)> = Some(('x', unsafe { TransmuteChar { a: !0 }.b }));
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR is undefined behavior
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-enum.rs:22:1
|
||||
|
|
||||
LL | const BAD_ENUM: Enum = unsafe { TransmuteEnum { a: &1 }.b };
|
||||
|
|
@ -6,7 +6,7 @@ LL | const BAD_ENUM: Enum = unsafe { TransmuteEnum { a: &1 }.b };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-enum.rs:35:1
|
||||
|
|
||||
LL | const BAD_ENUM2 : Enum2 = unsafe { TransmuteEnum2 { a: 0 }.b };
|
||||
|
|
@ -14,7 +14,7 @@ LL | const BAD_ENUM2 : Enum2 = unsafe { TransmuteEnum2 { a: 0 }.b };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-enum.rs:45:1
|
||||
|
|
||||
LL | const BAD_ENUM_CHAR : Option<(char, char)> = Some(('x', unsafe { TransmuteChar { a: !0 }.b }));
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ use std::ptr::NonNull;
|
|||
use std::num::{NonZeroU8, NonZeroUsize};
|
||||
|
||||
const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-nonnull.rs:17:1
|
||||
|
|
||||
LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
||||
|
|
@ -6,7 +6,7 @@ LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-nonnull.rs:20:1
|
||||
|
|
||||
LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
||||
|
|
@ -14,7 +14,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-nonnull.rs:22:1
|
||||
|
|
||||
LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) };
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@
|
|||
use std::mem;
|
||||
|
||||
const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref.rs:15:1
|
||||
|
|
||||
LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
||||
|
|
@ -6,7 +6,7 @@ LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref.rs:18:1
|
||||
|
|
||||
LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
||||
|
|
@ -14,7 +14,7 @@ LL | const NULL: &u16 = unsafe { mem::transmute(0usize) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref.rs:21:1
|
||||
|
|
||||
LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
||||
|
|
@ -22,7 +22,7 @@ LL | const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref.rs:24:1
|
||||
|
|
||||
LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
||||
|
|
@ -30,7 +30,7 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }];
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-ref.rs:27:1
|
||||
|
|
||||
LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) };
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ use std::mem;
|
|||
enum Bar {}
|
||||
|
||||
const BAD_BAD_BAD: Bar = unsafe { mem::transmute(()) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
const BAD_BAD_ARRAY: [Bar; 1] = unsafe { mem::transmute(()) };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-uninhabit.rs:18:1
|
||||
|
|
||||
LL | const BAD_BAD_BAD: Bar = unsafe { mem::transmute(()) };
|
||||
|
|
@ -6,7 +6,7 @@ LL | const BAD_BAD_BAD: Bar = unsafe { mem::transmute(()) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-uninhabit.rs:21:1
|
||||
|
|
||||
LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
||||
|
|
@ -14,7 +14,7 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-uninhabit.rs:24:1
|
||||
|
|
||||
LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { mem::transmute(()) };
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
use std::mem;
|
||||
|
||||
const BAD_UPVAR: &FnOnce() = &{ //~ ERROR this constant likely exhibits undefined behavior
|
||||
const BAD_UPVAR: &FnOnce() = &{ //~ ERROR it is undefined behavior to use this value
|
||||
let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
|
||||
let another_var = 13;
|
||||
move || { let _ = bad_ref; let _ = another_var; }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/ub-upvars.rs:15:1
|
||||
|
|
||||
LL | / const BAD_UPVAR: &FnOnce() = &{ //~ ERROR this constant likely exhibits undefined behavior
|
||||
LL | / const BAD_UPVAR: &FnOnce() = &{ //~ ERROR it is undefined behavior to use this value
|
||||
LL | | let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
|
||||
LL | | let another_var = 13;
|
||||
LL | | move || { let _ = bad_ref; let _ = another_var; }
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const fn read_field2() -> Field2 {
|
|||
}
|
||||
|
||||
const fn read_field3() -> Field3 {
|
||||
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR cannot be used
|
||||
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of this value
|
||||
FIELD3
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/union-const-eval-field.rs:37:5
|
||||
|
|
||||
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR cannot be used
|
||||
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of this value
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ union DummyUnion {
|
|||
|
||||
const UNION: DummyUnion = DummyUnion { field1: 1065353216 };
|
||||
|
||||
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used
|
||||
const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR will cause an error
|
||||
|
||||
const FIELD_PATH: Struct = Struct { //~ ERROR this constant likely exhibits undefined behavior
|
||||
const FIELD_PATH: Struct = Struct { //~ ERROR it is undefined behavior to use this value
|
||||
a: 42,
|
||||
b: unsafe { UNION.field3 },
|
||||
};
|
||||
|
|
@ -32,7 +32,7 @@ struct Struct {
|
|||
b: Field3,
|
||||
}
|
||||
|
||||
const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR this constant likely exhibits undefined behavior
|
||||
const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR it is undefined behavior to use this value
|
||||
b: [
|
||||
21,
|
||||
unsafe { UNION.field3 },
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/union-ice.rs:23:1
|
||||
|
|
||||
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used
|
||||
LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR will cause an error
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ice.rs:25:1
|
||||
|
|
||||
LL | / const FIELD_PATH: Struct = Struct { //~ ERROR this constant likely exhibits undefined behavior
|
||||
LL | / const FIELD_PATH: Struct = Struct { //~ ERROR it is undefined behavior to use this value
|
||||
LL | | a: 42,
|
||||
LL | | b: unsafe { UNION.field3 },
|
||||
LL | | };
|
||||
|
|
@ -17,10 +17,10 @@ LL | | };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ice.rs:35:1
|
||||
|
|
||||
LL | / const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR this constant likely exhibits undefined behavior
|
||||
LL | / const FIELD_PATH2: Struct2 = Struct2 { //~ ERROR it is undefined behavior to use this value
|
||||
LL | | b: [
|
||||
LL | | 21,
|
||||
LL | | unsafe { UNION.field3 },
|
||||
|
|
|
|||
|
|
@ -85,55 +85,56 @@ type MySliceBool = MySlice<[bool]>;
|
|||
const A: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.str};
|
||||
// bad str
|
||||
const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// bad str
|
||||
const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// bad str in user-defined unsized type
|
||||
const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// OK
|
||||
const A2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 1 } }.slice};
|
||||
// bad slice
|
||||
const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// bad slice
|
||||
const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// bad trait object
|
||||
const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// bad trait object
|
||||
const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// bad trait object
|
||||
const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// bad data *inside* the trait object
|
||||
const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// bad data *inside* the slice
|
||||
const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }];
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// good MySliceBool
|
||||
const I1: &MySliceBool = &MySlice(true, [false]);
|
||||
// bad: sized field is not okay
|
||||
const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]);
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// bad: unsized part is not okay
|
||||
const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]);
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// invalid UTF-8
|
||||
const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
// invalid UTF-8 in user-defined str-like
|
||||
const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:87:1
|
||||
|
|
||||
LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.str};
|
||||
|
|
@ -6,7 +6,7 @@ LL | const B: &str = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len:
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:90:1
|
||||
|
|
||||
LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.str};
|
||||
|
|
@ -14,7 +14,7 @@ LL | const C: &str = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:93:1
|
||||
|
|
||||
LL | const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.my_str};
|
||||
|
|
@ -22,7 +22,7 @@ LL | const C2: &MyStr = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42,
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:99:1
|
||||
|
|
||||
LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len: 999 } }.slice};
|
||||
|
|
@ -30,7 +30,7 @@ LL | const B2: &[u8] = unsafe { SliceTransmute { repr: SliceRepr { ptr: &42, len
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:102:1
|
||||
|
|
||||
LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, len: &3 } }.slice};
|
||||
|
|
@ -38,7 +38,7 @@ LL | const C3: &[u8] = unsafe { SliceTransmute { bad: BadSliceRepr { ptr: &42, l
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:106:1
|
||||
|
|
||||
LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable: &3 } }.rust};
|
||||
|
|
@ -46,7 +46,7 @@ LL | const D: &Trait = unsafe { DynTransmute { repr: DynRepr { ptr: &92, vtable:
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:109:1
|
||||
|
|
||||
LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtable: &3 } }.rust};
|
||||
|
|
@ -54,7 +54,7 @@ LL | const E: &Trait = unsafe { DynTransmute { repr2: DynRepr2 { ptr: &92, vtabl
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:112:1
|
||||
|
|
||||
LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtable: 3 } }.rust};
|
||||
|
|
@ -62,7 +62,7 @@ LL | const F: &Trait = unsafe { DynTransmute { bad: BadDynRepr { ptr: &92, vtabl
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:116:1
|
||||
|
|
||||
LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
||||
|
|
@ -70,40 +70,40 @@ LL | const G: &Trait = &unsafe { BoolTransmute { val: 3 }.bl };
|
|||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
--> $DIR/union-ub-fat-ptr.rs:119:1
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:120:1
|
||||
|
|
||||
LL | const H: &[bool] = &[unsafe { BoolTransmute { val: 3 }.bl }];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>[0], but expected something in the range 0..=1
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
--> $DIR/union-ub-fat-ptr.rs:125:1
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:126:1
|
||||
|
|
||||
LL | const I2: &MySliceBool = &MySlice(unsafe { BoolTransmute { val: 3 }.bl }, [false]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.0, but expected something in the range 0..=1
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
--> $DIR/union-ub-fat-ptr.rs:128:1
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:129:1
|
||||
|
|
||||
LL | const I3: &MySliceBool = &MySlice(true, [unsafe { BoolTransmute { val: 3 }.bl }]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 3 at .<deref>.1[0], but expected something in the range 0..=1
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
--> $DIR/union-ub-fat-ptr.rs:132:1
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:133:1
|
||||
|
|
||||
LL | const J1: &str = unsafe { SliceTransmute { slice: &[0xFF] }.str };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at .<deref>
|
||||
|
|
||||
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
|
||||
|
||||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
--> $DIR/union-ub-fat-ptr.rs:135:1
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub-fat-ptr.rs:136:1
|
||||
|
|
||||
LL | const J2: &MyStr = unsafe { SliceTransmute { slice: &[0xFF] }.my_str };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized or non-UTF-8 data in str at .<deref>.0
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ union Bar {
|
|||
|
||||
// the value is not valid for bools
|
||||
const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
|
||||
//~^ ERROR this constant likely exhibits undefined behavior
|
||||
//~^ ERROR it is undefined behavior to use this value
|
||||
|
||||
// The value is not valid for any union variant, but that's fine
|
||||
// unions are just a convenient way to transmute bits around
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0080]: this constant likely exhibits undefined behavior
|
||||
error[E0080]: it is undefined behavior to use this value
|
||||
--> $DIR/union-ub.rs:36:1
|
||||
|
|
||||
LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool};
|
||||
|
|
|
|||
18
src/test/ui/consts/const-eval/unused-broken-const.rs
Normal file
18
src/test/ui/consts/const-eval/unused-broken-const.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// 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.
|
||||
|
||||
// make sure that an *unused* broken const triggers an error even in a check build
|
||||
|
||||
// compile-flags: --emit=dep-info,metadata
|
||||
|
||||
const FOO: i32 = [][0];
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
fn main() {}
|
||||
14
src/test/ui/consts/const-eval/unused-broken-const.stderr
Normal file
14
src/test/ui/consts/const-eval/unused-broken-const.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type
|
||||
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/unused-broken-const.rs:15:1
|
||||
|
|
||||
LL | const FOO: i32 = [][0];
|
||||
| ^^^^^^^^^^^^^^^^^-----^
|
||||
| |
|
||||
| index out of bounds: the len is 0 but the index is 0
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-int-unchecked.rs:15:1
|
||||
|
|
||||
LL | const SHR: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
|
||||
|
|
@ -8,7 +8,7 @@ LL | const SHR: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
|
|||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-int-unchecked.rs:17:1
|
||||
|
|
||||
LL | const SHL: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ const X: usize = 42 && 39;
|
|||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARR: [i32; X] = [99; 34];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X1: usize = 42 || 39;
|
||||
//~^ ERROR mismatched types
|
||||
|
|
@ -25,6 +26,7 @@ const X1: usize = 42 || 39;
|
|||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARR1: [i32; X1] = [99; 47];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X2: usize = -42 || -39;
|
||||
//~^ ERROR mismatched types
|
||||
|
|
@ -34,6 +36,7 @@ const X2: usize = -42 || -39;
|
|||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARR2: [i32; X2] = [99; 18446744073709551607];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const X3: usize = -42 && -39;
|
||||
//~^ ERROR mismatched types
|
||||
|
|
@ -43,36 +46,43 @@ const X3: usize = -42 && -39;
|
|||
//~| ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARR3: [i32; X3] = [99; 6];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y: usize = 42.0 == 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARRR: [i32; Y] = [99; 1];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y1: usize = 42.0 >= 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARRR1: [i32; Y1] = [99; 1];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y2: usize = 42.0 <= 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARRR2: [i32; Y2] = [99; 1];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y3: usize = 42.0 > 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARRR3: [i32; Y3] = [99; 0];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y4: usize = 42.0 < 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARRR4: [i32; Y4] = [99; 0];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
const Y5: usize = 42.0 != 42.0;
|
||||
//~^ ERROR mismatched types
|
||||
//~| expected usize, found bool
|
||||
const ARRR5: [i32; Y5] = [99; 0];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
fn main() {
|
||||
let _ = ARR;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,14 @@ error[E0308]: mismatched types
|
|||
LL | const X: usize = 42 && 39;
|
||||
| ^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:18:18
|
||||
|
|
||||
LL | const ARR: [i32; X] = [99; 34];
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:20:19
|
||||
--> $DIR/const-integer-bool-ops.rs:21:19
|
||||
|
|
||||
LL | const X1: usize = 42 || 39;
|
||||
| ^^ expected bool, found integral variable
|
||||
|
|
@ -32,7 +38,7 @@ LL | const X1: usize = 42 || 39;
|
|||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:20:25
|
||||
--> $DIR/const-integer-bool-ops.rs:21:25
|
||||
|
|
||||
LL | const X1: usize = 42 || 39;
|
||||
| ^^ expected bool, found integral variable
|
||||
|
|
@ -41,13 +47,19 @@ LL | const X1: usize = 42 || 39;
|
|||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:20:19
|
||||
--> $DIR/const-integer-bool-ops.rs:21:19
|
||||
|
|
||||
LL | const X1: usize = 42 || 39;
|
||||
| ^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:28:19
|
||||
|
|
||||
LL | const ARR1: [i32; X1] = [99; 47];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:29:19
|
||||
--> $DIR/const-integer-bool-ops.rs:31:19
|
||||
|
|
||||
LL | const X2: usize = -42 || -39;
|
||||
| ^^^ expected bool, found integral variable
|
||||
|
|
@ -56,7 +68,7 @@ LL | const X2: usize = -42 || -39;
|
|||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:29:26
|
||||
--> $DIR/const-integer-bool-ops.rs:31:26
|
||||
|
|
||||
LL | const X2: usize = -42 || -39;
|
||||
| ^^^ expected bool, found integral variable
|
||||
|
|
@ -65,14 +77,20 @@ LL | const X2: usize = -42 || -39;
|
|||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:29:19
|
||||
--> $DIR/const-integer-bool-ops.rs:31:19
|
||||
|
|
||||
LL | const X2: usize = -42 || -39;
|
||||
| ^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0308]: mismatched types
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:38:19
|
||||
|
|
||||
LL | const ARR2: [i32; X2] = [99; 18446744073709551607];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:41:19
|
||||
|
|
||||
LL | const X3: usize = -42 && -39;
|
||||
| ^^^ expected bool, found integral variable
|
||||
|
|
||||
|
|
@ -80,7 +98,7 @@ LL | const X3: usize = -42 && -39;
|
|||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:38:26
|
||||
--> $DIR/const-integer-bool-ops.rs:41:26
|
||||
|
|
||||
LL | const X3: usize = -42 && -39;
|
||||
| ^^^ expected bool, found integral variable
|
||||
|
|
@ -89,47 +107,90 @@ LL | const X3: usize = -42 && -39;
|
|||
found type `{integer}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:38:19
|
||||
--> $DIR/const-integer-bool-ops.rs:41:19
|
||||
|
|
||||
LL | const X3: usize = -42 && -39;
|
||||
| ^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:48:19
|
||||
|
|
||||
LL | const ARR3: [i32; X3] = [99; 6];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:47:18
|
||||
--> $DIR/const-integer-bool-ops.rs:51:18
|
||||
|
|
||||
LL | const Y: usize = 42.0 == 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:52:19
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:54:19
|
||||
|
|
||||
LL | const Y1: usize = 42.0 >= 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
LL | const ARRR: [i32; Y] = [99; 1];
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:57:19
|
||||
|
|
||||
LL | const Y1: usize = 42.0 >= 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:60:20
|
||||
|
|
||||
LL | const ARRR1: [i32; Y1] = [99; 1];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:63:19
|
||||
|
|
||||
LL | const Y2: usize = 42.0 <= 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:66:20
|
||||
|
|
||||
LL | const ARRR2: [i32; Y2] = [99; 1];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:62:19
|
||||
--> $DIR/const-integer-bool-ops.rs:69:19
|
||||
|
|
||||
LL | const Y3: usize = 42.0 > 42.0;
|
||||
| ^^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:72:20
|
||||
|
|
||||
LL | const ARRR3: [i32; Y3] = [99; 0];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:67:19
|
||||
--> $DIR/const-integer-bool-ops.rs:75:19
|
||||
|
|
||||
LL | const Y4: usize = 42.0 < 42.0;
|
||||
| ^^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:78:20
|
||||
|
|
||||
LL | const ARRR4: [i32; Y4] = [99; 0];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/const-integer-bool-ops.rs:72:19
|
||||
--> $DIR/const-integer-bool-ops.rs:81:19
|
||||
|
|
||||
LL | const Y5: usize = 42.0 != 42.0;
|
||||
| ^^^^^^^^^^^^ expected usize, found bool
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-integer-bool-ops.rs:84:20
|
||||
|
|
||||
LL | const ARRR5: [i32; Y5] = [99; 0];
|
||||
| ^^ referenced constant has errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: aborting due to 28 previous errors
|
||||
|
||||
Some errors occurred: E0080, E0308.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -15,11 +15,9 @@
|
|||
const ONE: usize = 1;
|
||||
const TWO: usize = 2;
|
||||
const LEN: usize = ONE - TWO;
|
||||
//~^ ERROR any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
let a: [i8; LEN] = unimplemented!();
|
||||
//~^ ERROR E0080
|
||||
//~| ERROR E0080
|
||||
//~| ERROR E0080
|
||||
//~| ERROR E0080
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,19 @@
|
|||
error[E0080]: referenced constant has errors
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:17:1
|
||||
|
|
||||
LL | const LEN: usize = ONE - TWO;
|
||||
| --------- attempt to subtract with overflow
|
||||
...
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^---------^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error[E0080]: could not evaluate constant
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:21:17
|
||||
|
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
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
|
||||
...
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0080]: could not evaluate constant expression
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:12
|
||||
|
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^^^---^
|
||||
| |
|
||||
| referenced constant has errors
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ const TWO: usize = 2;
|
|||
|
||||
fn main() {
|
||||
let a: [i8; ONE - TWO] = unimplemented!();
|
||||
//~^ ERROR could not evaluate constant expression
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
//~| attempt to subtract with overflow
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
error: attempt to subtract with overflow
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-len-underflow-subspans.rs:18:17
|
||||
|
|
||||
LL | let a: [i8; ONE - TWO] = unimplemented!();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
| ^^^^^^^^^ attempt to subtract with overflow
|
||||
|
||||
error[E0080]: could not evaluate constant expression
|
||||
--> $DIR/const-len-underflow-subspans.rs:18:12
|
||||
|
|
||||
LL | let a: [i8; ONE - TWO] = unimplemented!();
|
||||
| ^^^^^---------^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -1,17 +1,27 @@
|
|||
error[E0391]: cycle detected when computing layout of `Foo`
|
||||
error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}`
|
||||
--> $DIR/const-size_of-cycle.rs:16:17
|
||||
|
|
||||
LL | bytes: [u8; std::mem::size_of::<Foo>()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`...
|
||||
note: ...which requires const-evaluating `Foo::bytes::{{constant}}`...
|
||||
--> $SRC_DIR/libcore/mem.rs:LL:COL
|
||||
|
|
||||
LL | intrinsics::size_of::<T>()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which again requires computing layout of `Foo`, completing the cycle
|
||||
note: cycle used when const-evaluating `Foo::bytes::{{constant}}`
|
||||
--> $SRC_DIR/libcore/mem.rs:LL:COL
|
||||
note: ...which requires computing layout of `Foo`...
|
||||
note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`...
|
||||
note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...
|
||||
--> $DIR/const-size_of-cycle.rs:16:17
|
||||
|
|
||||
LL | intrinsics::size_of::<T>()
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL | bytes: [u8; std::mem::size_of::<Foo>()]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle
|
||||
note: cycle used when processing `Foo`
|
||||
--> $DIR/const-size_of-cycle.rs:15:1
|
||||
|
|
||||
LL | struct Foo {
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
const FOO: &'static[u32] = &[1, 2, 3];
|
||||
const BAR: u32 = FOO[5];
|
||||
//~^ index out of bounds: the len is 3 but the index is 5
|
||||
//~| ERROR this constant cannot be used
|
||||
//~| ERROR any use of this value will cause an error
|
||||
|
||||
fn main() {
|
||||
let _ = BAR;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: this constant cannot be used
|
||||
error: any use of this value will cause an error
|
||||
--> $DIR/const-slice-oob.rs:14:1
|
||||
|
|
||||
LL | const BAR: u32 = FOO[5];
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ const TUP: (usize,) = 5usize << 64;
|
|||
//~^ ERROR mismatched types
|
||||
//~| expected tuple, found usize
|
||||
const ARR: [i32; TUP.0] = [];
|
||||
//~^ ERROR evaluation of constant value failed
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,13 @@ LL | const TUP: (usize,) = 5usize << 64;
|
|||
= note: expected type `(usize,)`
|
||||
found type `usize`
|
||||
|
||||
error: aborting due to previous error
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/const-tup-index-span.rs:16:18
|
||||
|
|
||||
LL | const ARR: [i32; TUP.0] = [];
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0080, E0308.
|
||||
For more information about an error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ enum Enum {
|
|||
X = (1 << 500), //~ ERROR E0080
|
||||
//~| shift left with overflow
|
||||
Y = (1 / 0) //~ ERROR E0080
|
||||
//~| const_err
|
||||
//~| const_err
|
||||
//~| const_err
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,37 +1,15 @@
|
|||
error: attempt to shift left with overflow
|
||||
--> $DIR/E0080.rs:12:9
|
||||
|
|
||||
LL | X = (1 << 500), //~ ERROR E0080
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(exceeding_bitshifts)] on by default
|
||||
|
||||
error[E0080]: could not evaluate enum discriminant
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/E0080.rs:12:9
|
||||
|
|
||||
LL | X = (1 << 500), //~ ERROR E0080
|
||||
| ^^^^^^^^^^ attempt to shift left with overflow
|
||||
|
||||
error: attempt to divide by zero
|
||||
--> $DIR/E0080.rs:14:9
|
||||
|
|
||||
LL | Y = (1 / 0) //~ ERROR E0080
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: this expression will panic at runtime
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/E0080.rs:14:9
|
||||
|
|
||||
LL | Y = (1 / 0) //~ ERROR E0080
|
||||
| ^^^^^^^ attempt to divide by zero
|
||||
|
||||
error[E0080]: could not evaluate enum discriminant
|
||||
--> $DIR/E0080.rs:14:9
|
||||
|
|
||||
LL | Y = (1 / 0) //~ ERROR E0080
|
||||
| ^^^^^^^ attempt to divide by zero
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue