]> git.lizzy.rs Git - rust.git/commitdiff
add test for issue 69020
authorRalf Jung <post@ralfj.de>
Sat, 15 Feb 2020 10:00:14 +0000 (11:00 +0100)
committerRalf Jung <post@ralfj.de>
Sat, 15 Feb 2020 10:00:14 +0000 (11:00 +0100)
src/test/ui/consts/issue-69020.default.stderr [new file with mode: 0644]
src/test/ui/consts/issue-69020.noopt.stderr [new file with mode: 0644]
src/test/ui/consts/issue-69020.opt.stderr [new file with mode: 0644]
src/test/ui/consts/issue-69020.opt_with_overflow_checks.stderr [new file with mode: 0644]
src/test/ui/consts/issue-69020.rs [new file with mode: 0644]

diff --git a/src/test/ui/consts/issue-69020.default.stderr b/src/test/ui/consts/issue-69020.default.stderr
new file mode 100644 (file)
index 0000000..0bf40ce
--- /dev/null
@@ -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 (file)
index 0000000..0bf40ce
--- /dev/null
@@ -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 (file)
index 0000000..0bf40ce
--- /dev/null
@@ -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 (file)
index 0000000..0bf40ce
--- /dev/null
@@ -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 (file)
index 0000000..9f1ed86
--- /dev/null
@@ -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<T: Foo> Foo for Vec<T> {
+    const N: i32 = -i32::MIN + T::N;
+    //~^ ERROR arithmetic operation will overflow
+}