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:
commit
19c65022fc
17
tests/codegen/vecdeque-nonempty-get-no-panic.rs
Normal file
17
tests/codegen/vecdeque-nonempty-get-no-panic.rs
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user