Skip to content

Commit

Permalink
Auto merge of rust-lang#116047 - a-lafrance:I80836-codegen-test, r=Ma…
Browse files Browse the repository at this point in the history
…rk-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.
  • Loading branch information
bors committed Sep 23, 2023
2 parents 3050938 + d5ec9af commit 19c6502
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/codegen/vecdeque-nonempty-get-no-panic.rs
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit 19c6502

Please sign in to comment.