Skip to content

Commit

Permalink
Add a MIR pre-codegen test for Vec::deref
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Mar 29, 2024
1 parent 1c19595 commit 556216a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/mir-opt/pre-codegen/vec_deref.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// skip-filecheck
//@ compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY

#![crate_type = "lib"]

// Added after it stopped inlining in a nightly; see
// <https://github.com/rust-lang/rust/issues/123174>

// EMIT_MIR vec_deref.vec_deref_to_slice.PreCodegen.after.mir
pub fn vec_deref_to_slice(v: &Vec<u8>) -> &[u8] {
v
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// MIR for `vec_deref_to_slice` after PreCodegen

fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
debug v => _1;
let mut _0: &[u8];

bb0: {
_0 = <Vec<u8> as Deref>::deref(move _1) -> [return: bb1, unwind unreachable];
}

bb1: {
return;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// MIR for `vec_deref_to_slice` after PreCodegen

fn vec_deref_to_slice(_1: &Vec<u8>) -> &[u8] {
debug v => _1;
let mut _0: &[u8];

bb0: {
_0 = <Vec<u8> as Deref>::deref(move _1) -> [return: bb1, unwind continue];
}

bb1: {
return;
}
}

0 comments on commit 556216a

Please sign in to comment.