summaryrefslogtreecommitdiffstats
path: root/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs')
-rw-r--r--tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs
new file mode 100644
index 000000000..565b7e86f
--- /dev/null
+++ b/tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs
@@ -0,0 +1,12 @@
+// run-fail
+// error-pattern:thread 'main' panicked at 'attempt to negate with overflow'
+// ignore-emscripten no processes
+// compile-flags: -C debug-assertions
+
+#![allow(arithmetic_overflow)]
+
+use std::num::NonZeroI8;
+
+fn main() {
+ let _x = -NonZeroI8::new(i8::MIN).unwrap();
+}