about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-10-03 21:52:47 +0200
committerGitHub <noreply@github.com>2024-10-03 21:52:47 +0200
commit29580e12f2eccf7ff8d50999bc82174292532c7d (patch)
tree594a4f5bc390c97d0c00e47839b382aabce5ece2 /tests/codegen
parent6753e07d465f619566772906bc63f0e130a4cd41 (diff)
parentd47e388843f682f57262f020edd9909c850a0c49 (diff)
Rollup merge of #131197 - EFanZh:avoid-emptyness-check-in-peekmut-pop, r=Amanieu
Avoid emptiness check in `PeekMut::pop`

This PR avoids an unnecessary emptiness check in `PeekMut::pop` by replacing `Option::unwrap` with `Option::unwrap_unchecked`.
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/binary-heap-peek-mut-pop-no-panic.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs
new file mode 100644
index 00000000000..9cf4f210e52
--- /dev/null
+++ b/tests/codegen/binary-heap-peek-mut-pop-no-panic.rs
@@ -0,0 +1,13 @@
+//@ compile-flags: -O
+//@ ignore-debug
+#![crate_type = "lib"]
+
+use std::collections::binary_heap::PeekMut;
+
+// CHECK-LABEL: @peek_mut_pop
+#[no_mangle]
+pub fn peek_mut_pop(peek_mut: PeekMut<u32>) -> u32 {
+    // CHECK-NOT: panic
+    // CHECK-NOT: unwrap_failed
+    PeekMut::pop(peek_mut)
+}