Auto merge of #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 #80836. Ensures that Rustc optimizes away the panic when unwrapping the result of `.get(0)` because of the `!is_empty()` condition.
This commit is contained in:
bors 2023-09-23 16:38:20 +00:00
commit 19c65022fc

View File

@ -0,0 +1,17 @@
// Guards against regression for optimization discussed in issue #80836
// compile-flags: -O
// ignore-debug: the debug assertions get in the way
#![crate_type = "lib"]
use std::collections::VecDeque;
// CHECK-LABEL: @front
// CHECK: ret void
#[no_mangle]
pub fn front(v: VecDeque<usize>) {
if !v.is_empty() {
v.get(0).unwrap();
}
}