Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shrink from_raw_parts's MIR so that Vec::deref MIR-inlines again #123190

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add a MIR pre-codegen test for Vec::deref
scottmcm committed Mar 29, 2024
commit 556216a79e541c0101cdf987d36785000711663f
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;
}
}