about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-03-06 13:41:07 +0000
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-03-06 13:41:07 +0000
commit33d7fad7e5360097da6dfe27aa24ea79ef3db82f (patch)
treeb9564a8f655154c9c1bc204e056cf60e03d10ab6 /tests
parentac4379fea9e83465d814bb05005689f49bd2141e (diff)
downloadrust-33d7fad7e5360097da6dfe27aa24ea79ef3db82f.tar.gz
rust-33d7fad7e5360097da6dfe27aa24ea79ef3db82f.zip
Add regression test for 98444
Diffstat (limited to 'tests')
-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
+