From: Ralf Jung Date: Sat, 15 Feb 2020 10:00:14 +0000 (+0100) Subject: add test for issue 69020 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=4b8c78496815e22652fdf0da216659fe06936b50;p=rust.git add test for issue 69020 --- diff --git a/src/test/ui/consts/issue-69020.default.stderr b/src/test/ui/consts/issue-69020.default.stderr new file mode 100644 index 00000000000..0bf40ce4b31 --- /dev/null +++ b/src/test/ui/consts/issue-69020.default.stderr @@ -0,0 +1,10 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-69020.rs:15:20 + | +LL | const N: i32 = -i32::MIN + T::N; + | ^^^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(overflow)]` on by default + +error: aborting due to previous error + diff --git a/src/test/ui/consts/issue-69020.noopt.stderr b/src/test/ui/consts/issue-69020.noopt.stderr new file mode 100644 index 00000000000..0bf40ce4b31 --- /dev/null +++ b/src/test/ui/consts/issue-69020.noopt.stderr @@ -0,0 +1,10 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-69020.rs:15:20 + | +LL | const N: i32 = -i32::MIN + T::N; + | ^^^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(overflow)]` on by default + +error: aborting due to previous error + diff --git a/src/test/ui/consts/issue-69020.opt.stderr b/src/test/ui/consts/issue-69020.opt.stderr new file mode 100644 index 00000000000..0bf40ce4b31 --- /dev/null +++ b/src/test/ui/consts/issue-69020.opt.stderr @@ -0,0 +1,10 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-69020.rs:15:20 + | +LL | const N: i32 = -i32::MIN + T::N; + | ^^^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(overflow)]` on by default + +error: aborting due to previous error + diff --git a/src/test/ui/consts/issue-69020.opt_with_overflow_checks.stderr b/src/test/ui/consts/issue-69020.opt_with_overflow_checks.stderr new file mode 100644 index 00000000000..0bf40ce4b31 --- /dev/null +++ b/src/test/ui/consts/issue-69020.opt_with_overflow_checks.stderr @@ -0,0 +1,10 @@ +error: this arithmetic operation will overflow + --> $DIR/issue-69020.rs:15:20 + | +LL | const N: i32 = -i32::MIN + T::N; + | ^^^^^^^^^ attempt to negate with overflow + | + = note: `#[deny(overflow)]` on by default + +error: aborting due to previous error + diff --git a/src/test/ui/consts/issue-69020.rs b/src/test/ui/consts/issue-69020.rs new file mode 100644 index 00000000000..9f1ed862c7b --- /dev/null +++ b/src/test/ui/consts/issue-69020.rs @@ -0,0 +1,17 @@ +// revisions: default noopt opt opt_with_overflow_checks +//[noopt]compile-flags: -C opt-level=0 +//[opt]compile-flags: -O +//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O + +#![crate_type="lib"] + +use std::i32; + +pub trait Foo { + const N: i32; +} + +impl Foo for Vec { + const N: i32 = -i32::MIN + T::N; + //~^ ERROR arithmetic operation will overflow +}