Closed
Description
#![allow(warnings)]
fn needs_slice(s: &[u8]) {}
fn gives_array(a: u8) {
needs_slice(&[a])
}
fn main() {}
Mir from tcx.optimized_mir
:
fn gives_array(_1: u8) -> (){
let mut _0: (); // return place
let mut _2: &[u8];
let mut _3: &[u8; 1];
let mut _4: &[u8; 1];
let mut _5: [u8; 1];
let mut _6: u8;
bb0: {
StorageLive(_2); // bb0[0]: scope 0 at src/main.rs:6:17: 6:21
StorageLive(_3); // bb0[1]: scope 0 at src/main.rs:6:17: 6:21
StorageLive(_4); // bb0[2]: scope 0 at src/main.rs:6:17: 6:21
StorageLive(_5); // bb0[3]: scope 0 at src/main.rs:6:18: 6:21
StorageLive(_6); // bb0[4]: scope 0 at src/main.rs:6:19: 6:20
_6 = _1; // bb0[5]: scope 0 at src/main.rs:6:19: 6:20
_5 = [move _6]; // bb0[6]: scope 0 at src/main.rs:6:18: 6:21
StorageDead(_6); // bb0[7]: scope 0 at src/main.rs:6:20: 6:21
_4 = &_5; // bb0[8]: scope 0 at src/main.rs:6:17: 6:21
_3 = _4; // bb0[9]: scope 0 at src/main.rs:6:17: 6:21
_2 = move _3 as &[u8] (Unsize); // bb0[10]: scope 0 at src/main.rs:6:17: 6:21
StorageDead(_3); // bb0[11]: scope 0 at src/main.rs:6:20: 6:21
_0 = const needs_slice(move _2) -> bb1; // bb0[12]: scope 0 at src/main.rs:6:5: 6:22
// ty::Const
// + ty: for<'r> fn(&'r [u8]) {needs_slice}
// + val: Value(ByVal(Undef))
// mir::Constant
// + span: src/main.rs:6:5: 6:16
// + ty: for<'r> fn(&'r [u8]) {needs_slice}
// + literal: const needs_slice
}
bb1: {
StorageDead(_2); // bb1[0]: scope 0 at src/main.rs:6:21: 6:22
StorageDead(_4); // bb1[1]: scope 0 at src/main.rs:7:1: 7:2
StorageDead(_5); // bb1[2]: scope 0 at src/main.rs:7:1: 7:2
return; // bb1[3]: scope 0 at src/main.rs:7:2: 7:2
}
}
This contains an aggregate (_5 = [move _6];
), while the docs of Rvalue::Aggregate
seem to imply that it shouldn't exist after optimizations:
These rvalues can be optimized away after type-checking and before lowering.
Metadata
Metadata
Assignees
Labels
No labels