Skip to content

Commit 19c6502

Browse files
committed
Auto merge of rust-lang#116047 - a-lafrance:I80836-codegen-test, r=Mark-Simulacrum
Add codegen test to guard against VecDeque optimization regression Very small PR that adds a codegen test to guard against regression for the `VecDeque` optimization addressed in rust-lang#80836. Ensures that Rustc optimizes away the panic when unwrapping the result of `.get(0)` because of the `!is_empty()` condition.
2 parents 3050938 + d5ec9af commit 19c6502

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Guards against regression for optimization discussed in issue #80836
2+
3+
// compile-flags: -O
4+
// ignore-debug: the debug assertions get in the way
5+
6+
#![crate_type = "lib"]
7+
8+
use std::collections::VecDeque;
9+
10+
// CHECK-LABEL: @front
11+
// CHECK: ret void
12+
#[no_mangle]
13+
pub fn front(v: VecDeque<usize>) {
14+
if !v.is_empty() {
15+
v.get(0).unwrap();
16+
}
17+
}

0 commit comments

Comments
 (0)