about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-03-06 16:42:01 +0100
committerGitHub <noreply@github.com>2023-03-06 16:42:01 +0100
commit567cab93d5b32cbd85fd583cbc7f886551fca379 (patch)
tree1dbc07e3e00d0cb423f0b1d944deb1435dff00ee
parent3279f7ed773d330616e799537cdbf53179cb0eab (diff)
parent33d7fad7e5360097da6dfe27aa24ea79ef3db82f (diff)
downloadrust-567cab93d5b32cbd85fd583cbc7f886551fca379.tar.gz
rust-567cab93d5b32cbd85fd583cbc7f886551fca379.zip
Rollup merge of #108812 - albertlarsan68:test-98444, r=Nilstrieb
Add regression test for #98444

cc #108730 this will need to be changed to a `check-fail` test once it lands.

Fixes #98444
-rw-r--r--tests/ui/lint/unconditional_panic_98444.rs7
-rw-r--r--tests/ui/lint/unconditional_panic_98444.stderr10
2 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/lint/unconditional_panic_98444.rs b/tests/ui/lint/unconditional_panic_98444.rs
new file mode 100644
index 00000000000..011fabfbbe9
--- /dev/null
+++ b/tests/ui/lint/unconditional_panic_98444.rs
@@ -0,0 +1,7 @@
+// build-fail
+
+fn main() {
+    let xs: [i32; 5] = [1, 2, 3, 4, 5];
+    let _ = &xs;
+    let _ = xs[7]; //~ ERROR: this operation will panic at runtime [unconditional_panic]
+}
diff --git a/tests/ui/lint/unconditional_panic_98444.stderr b/tests/ui/lint/unconditional_panic_98444.stderr
new file mode 100644
index 00000000000..a347458097f
--- /dev/null
+++ b/tests/ui/lint/unconditional_panic_98444.stderr
@@ -0,0 +1,10 @@
+error: this operation will panic at runtime
+  --> $DIR/unconditional_panic_98444.rs:6:13
+   |
+LL |     let _ = xs[7];
+   |             ^^^^^ index out of bounds: the length is 5 but the index is 7
+   |
+   = note: `#[deny(unconditional_panic)]` on by default
+
+error: aborting due to previous error
+