Add a MIR pre-codegen test for Vec::deref

This commit is contained in:
Scott McMurray 2024-03-29 00:37:31 -07:00
parent 5800dc1faa
commit b76faff1b2
3 changed files with 41 additions and 0 deletions

View File

@ -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
}

View File

@ -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;
}
}

View File

@ -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;
}
}