Don't const propagate the body of constants
This commit is contained in:
parent
4bb9648b27
commit
4eea1a4e5e
@ -45,8 +45,11 @@ impl MirPass for ConstProp {
|
||||
return;
|
||||
}
|
||||
match tcx.describe_def(source.def_id) {
|
||||
// skip statics because they'll be evaluated by miri anyway
|
||||
// skip statics/consts because they'll be evaluated by miri anyway
|
||||
Some(Def::Const(..)) |
|
||||
Some(Def::Static(..)) => return,
|
||||
// we still run on associated constants, because they might not get evaluated
|
||||
// within the current crate
|
||||
_ => {},
|
||||
}
|
||||
trace!("ConstProp starting for {:?}", source.def_id);
|
||||
|
@ -11,16 +11,10 @@
|
||||
#![deny(const_err)]
|
||||
|
||||
pub const A: i8 = -std::i8::MIN; //~ ERROR const_err
|
||||
//~^ ERROR this constant cannot be used
|
||||
//~| ERROR this expression will panic at runtime
|
||||
pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err
|
||||
//~^ ERROR this constant cannot be used
|
||||
pub const C: u8 = 200u8 * 4; //~ ERROR const_err
|
||||
//~^ ERROR this constant cannot be used
|
||||
pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err
|
||||
//~^ ERROR this constant cannot be used
|
||||
pub const E: u8 = [5u8][1]; //~ ERROR const_err
|
||||
//~| ERROR this constant cannot be used
|
||||
|
||||
fn main() {
|
||||
let _a = A;
|
||||
|
@ -11,24 +11,16 @@
|
||||
#![deny(const_err)]
|
||||
|
||||
pub const A: i8 = -std::i8::MIN;
|
||||
//~^ ERROR attempt to negate with overflow
|
||||
//~| ERROR this expression will panic at runtime
|
||||
//~| ERROR this constant cannot be used
|
||||
//~^ ERROR this constant cannot be used
|
||||
pub const B: i8 = A;
|
||||
//~^ ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
pub const C: u8 = A as u8;
|
||||
//~^ ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
pub const D: i8 = 50 - A;
|
||||
//~^ ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
|
||||
fn main() {
|
||||
let _ = (A, B, C, D);
|
||||
|
@ -25,54 +25,46 @@ const VALS_I8: (i8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i8::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_I16: (i16,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i16::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_I32: (i32,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i32::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_I64: (i64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i64::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_U8: (u8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
u8::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_U16: (u16,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
u16::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_U32: (u32,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
u32::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
const VALS_U64: (u64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
u64::MIN - 1,
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
);
|
||||
|
||||
fn main() {
|
||||
|
@ -25,54 +25,46 @@ const VALS_I8: (i8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i8::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_I16: (i16,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i16::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_I32: (i32,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i32::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_I64: (i64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i64::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_U8: (u8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
u8::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_U16: (u16,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
u16::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_U32: (u32,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
u32::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
const VALS_U64: (u64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
u64::MAX + 1,
|
||||
//~^ ERROR attempt to add with overflow
|
||||
);
|
||||
|
||||
fn main() {
|
||||
|
@ -25,54 +25,46 @@ const VALS_I8: (i8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i8::MIN * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_I16: (i16,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i16::MIN * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_I32: (i32,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i32::MIN * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_I64: (i64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
i64::MIN * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_U8: (u8,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
u8::MAX * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_U16: (u16,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
u16::MAX * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_U32: (u32,) = (
|
||||
//~^ ERROR this constant cannot be used
|
||||
u32::MAX * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
const VALS_U64: (u64,) =
|
||||
//~^ ERROR this constant cannot be used
|
||||
(
|
||||
u64::MAX * 2,
|
||||
//~^ ERROR attempt to multiply with overflow
|
||||
);
|
||||
|
||||
fn main() {
|
||||
|
@ -1,15 +1,3 @@
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/conditional_array_execution.rs:15:19
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/conditional_array_execution.rs:11:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/conditional_array_execution.rs:15:1
|
||||
|
|
||||
@ -17,9 +5,15 @@ LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/conditional_array_execution.rs:11:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: referenced constant
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
@ -28,13 +22,13 @@ LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/conditional_array_execution.rs:20:5
|
||||
--> $DIR/conditional_array_execution.rs:19:5
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
@ -45,7 +39,7 @@ LL | println!("{}", FOO);
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/conditional_array_execution.rs:20:5
|
||||
--> $DIR/conditional_array_execution.rs:19:5
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^^^^^^^^^^^^^---^^
|
||||
@ -55,7 +49,7 @@ LL | println!("{}", FOO);
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
@ -64,7 +58,7 @@ LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
@ -13,8 +13,7 @@
|
||||
const X: u32 = 5;
|
||||
const Y: u32 = 6;
|
||||
const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this constant cannot be used
|
||||
//~^ WARN this constant cannot be used
|
||||
|
||||
fn main() {
|
||||
println!("{}", FOO);
|
||||
|
@ -1,15 +1,3 @@
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/conditional_array_execution.rs:15:19
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/conditional_array_execution.rs:11:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/conditional_array_execution.rs:15:1
|
||||
|
|
||||
@ -17,9 +5,15 @@ LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/conditional_array_execution.rs:11:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: referenced constant
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
@ -28,13 +22,13 @@ LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
|
||||
| ----- attempt to subtract with overflow
|
||||
@ -43,7 +37,7 @@ LL | println!("{}", FOO);
|
||||
| ^^^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/conditional_array_execution.rs:20:20
|
||||
--> $DIR/conditional_array_execution.rs:19:20
|
||||
|
|
||||
LL | println!("{}", FOO);
|
||||
| ^^^ referenced constant has errors
|
||||
|
@ -1,8 +1,10 @@
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/issue-43197.rs:20:20
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/issue-43197.rs:20:5
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| ^^^
|
||||
| ^^^^^^^^^^^^^^^---^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-43197.rs:11:9
|
||||
@ -11,21 +13,7 @@ LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/issue-43197.rs:20:5
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| ^^^^^^^^^^^^^^^---^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/issue-43197.rs:23:24
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| ^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/issue-43197.rs:23:5
|
||||
--> $DIR/issue-43197.rs:22:5
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| ^^^^^^^^^^^^^^^^^^^---^^
|
||||
@ -33,7 +21,7 @@ LL | const Y: u32 = foo(0-1);
|
||||
| attempt to subtract with overflow
|
||||
|
||||
warning: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
@ -42,28 +30,28 @@ LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | //~^ WARN this constant cannot be used
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:5
|
||||
--> $DIR/issue-43197.rs:24:5
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
@ -74,7 +62,7 @@ LL | println!("{} {}", X, Y);
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:26:5
|
||||
--> $DIR/issue-43197.rs:24:5
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^^^^^^^^^^^^^^^^^^-^^^^^
|
||||
@ -84,22 +72,22 @@ LL | println!("{} {}", X, Y);
|
||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | //~^ WARN this constant cannot be used
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
@ -108,7 +96,7 @@ LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
@ -18,11 +18,9 @@ const fn foo(x: u32) -> u32 {
|
||||
|
||||
fn main() {
|
||||
const X: u32 = 0-1;
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this constant cannot be used
|
||||
//~^ WARN this constant cannot be used
|
||||
const Y: u32 = foo(0-1);
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this constant cannot be used
|
||||
//~^ WARN this constant cannot be used
|
||||
println!("{} {}", X, Y);
|
||||
//~^ WARN this expression will panic at runtime
|
||||
//~| WARN this expression will panic at runtime
|
||||
|
@ -1,8 +1,10 @@
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/issue-43197.rs:20:20
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/issue-43197.rs:20:5
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| ^^^
|
||||
| ^^^^^^^^^^^^^^^---^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/issue-43197.rs:11:9
|
||||
@ -11,21 +13,7 @@ LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/issue-43197.rs:20:5
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| ^^^^^^^^^^^^^^^---^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/issue-43197.rs:23:24
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| ^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/issue-43197.rs:23:5
|
||||
--> $DIR/issue-43197.rs:22:5
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| ^^^^^^^^^^^^^^^^^^^---^^
|
||||
@ -33,7 +21,7 @@ LL | const Y: u32 = foo(0-1);
|
||||
| attempt to subtract with overflow
|
||||
|
||||
warning: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
@ -42,43 +30,43 @@ LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
warning: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | //~^ WARN this constant cannot be used
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
warning: this expression will panic at runtime
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | const Y: u32 = foo(0-1);
|
||||
| --- attempt to subtract with overflow
|
||||
...
|
||||
LL | //~^ WARN this constant cannot be used
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:26:26
|
||||
--> $DIR/issue-43197.rs:24:26
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | const X: u32 = 0-1;
|
||||
| --- attempt to subtract with overflow
|
||||
@ -87,7 +75,7 @@ LL | println!("{} {}", X, Y);
|
||||
| ^
|
||||
|
||||
error[E0080]: erroneous constant used
|
||||
--> $DIR/issue-43197.rs:26:23
|
||||
--> $DIR/issue-43197.rs:24:23
|
||||
|
|
||||
LL | println!("{} {}", X, Y);
|
||||
| ^ referenced constant has errors
|
||||
|
@ -14,8 +14,7 @@
|
||||
#![crate_type = "lib"]
|
||||
|
||||
pub const Z: u32 = 0 - 1;
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this constant cannot be used
|
||||
//~^ WARN this constant cannot be used
|
||||
|
||||
pub type Foo = [i32; 0 - 1];
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
|
@ -1,15 +1,3 @@
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/pub_const_err.rs:16:20
|
||||
|
|
||||
LL | pub const Z: u32 = 0 - 1;
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/pub_const_err.rs:12:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/pub_const_err.rs:16:1
|
||||
|
|
||||
@ -17,15 +5,21 @@ LL | pub const Z: u32 = 0 - 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^-----^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/pub_const_err.rs:12:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/pub_const_err.rs:20:22
|
||||
--> $DIR/pub_const_err.rs:19:22
|
||||
|
|
||||
LL | pub type Foo = [i32; 0 - 1];
|
||||
| ^^^^^
|
||||
|
||||
warning: this array length cannot be used
|
||||
--> $DIR/pub_const_err.rs:20:22
|
||||
--> $DIR/pub_const_err.rs:19:22
|
||||
|
|
||||
LL | pub type Foo = [i32; 0 - 1];
|
||||
| ^^^^^ attempt to subtract with overflow
|
||||
|
@ -12,8 +12,7 @@
|
||||
#![warn(const_err)]
|
||||
|
||||
pub const Z: u32 = 0 - 1;
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
//~| WARN this constant cannot be used
|
||||
//~^ WARN this constant cannot be used
|
||||
|
||||
pub type Foo = [i32; 0 - 1];
|
||||
//~^ WARN attempt to subtract with overflow
|
||||
|
@ -1,15 +1,3 @@
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/pub_const_err_bin.rs:14:20
|
||||
|
|
||||
LL | pub const Z: u32 = 0 - 1;
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/pub_const_err_bin.rs:12:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: this constant cannot be used
|
||||
--> $DIR/pub_const_err_bin.rs:14:1
|
||||
|
|
||||
@ -17,15 +5,21 @@ LL | pub const Z: u32 = 0 - 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^-----^
|
||||
| |
|
||||
| attempt to subtract with overflow
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/pub_const_err_bin.rs:12:9
|
||||
|
|
||||
LL | #![warn(const_err)]
|
||||
| ^^^^^^^^^
|
||||
|
||||
warning: attempt to subtract with overflow
|
||||
--> $DIR/pub_const_err_bin.rs:18:22
|
||||
--> $DIR/pub_const_err_bin.rs:17:22
|
||||
|
|
||||
LL | pub type Foo = [i32; 0 - 1];
|
||||
| ^^^^^
|
||||
|
||||
warning: this array length cannot be used
|
||||
--> $DIR/pub_const_err_bin.rs:18:22
|
||||
--> $DIR/pub_const_err_bin.rs:17:22
|
||||
|
|
||||
LL | pub type Foo = [i32; 0 - 1];
|
||||
| ^^^^^ attempt to subtract with overflow
|
||||
|
@ -15,7 +15,6 @@
|
||||
const ONE: usize = 1;
|
||||
const TWO: usize = 2;
|
||||
const LEN: usize = ONE - TWO;
|
||||
//~^ ERROR attempt to subtract with overflow
|
||||
|
||||
fn main() {
|
||||
let a: [i8; LEN] = unimplemented!();
|
||||
@ -23,4 +22,5 @@ fn main() {
|
||||
//~| ERROR E0080
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
//~| ERROR const_err
|
||||
}
|
||||
|
@ -1,13 +1,22 @@
|
||||
error: attempt to subtract with overflow
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:17:20
|
||||
error: referenced constant
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
||||
|
|
||||
LL | const LEN: usize = ONE - TWO;
|
||||
| ^^^^^^^^^
|
||||
| --------- attempt to subtract with overflow
|
||||
...
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
||||
|
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error: referenced constant
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:21:17
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:17
|
||||
|
|
||||
LL | const LEN: usize = ONE - TWO;
|
||||
| --------- attempt to subtract with overflow
|
||||
@ -15,14 +24,8 @@ LL | const LEN: usize = ONE - TWO;
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^
|
||||
|
||||
error: this expression will panic at runtime
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:21:17
|
||||
|
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^ referenced constant has errors
|
||||
|
||||
error[E0080]: referenced constant
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:21:12
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:12
|
||||
|
|
||||
LL | const LEN: usize = ONE - TWO;
|
||||
| --------- attempt to subtract with overflow
|
||||
@ -31,7 +34,7 @@ LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^^^^^^^
|
||||
|
||||
error[E0080]: could not evaluate constant expression
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:21:12
|
||||
--> $DIR/const-len-underflow-separate-spans.rs:20:12
|
||||
|
|
||||
LL | let a: [i8; LEN] = unimplemented!();
|
||||
| ^^^^^---^
|
||||
|
Loading…
Reference in New Issue
Block a user