Closed
Description
$ rustc foo.rs --crate-type lib --emit mir -Cpanic=abort
fn map(x: Option<Box<()>>) -> Option<Box<()>> {
match x {
None => None,
Some(x) => Some(x),
}
}
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn map(_1: std::option::Option<std::boxed::Box<()>>) -> std::option::Option<std::boxed::Box<()>> {
debug x => _1; // in scope 0 at a.rs:1:8: 1:9
let mut _0: std::option::Option<std::boxed::Box<()>>; // return place in scope 0 at a.rs:1:31: 1:46
let mut _2: isize; // in scope 0 at a.rs:3:9: 3:13
let _3: std::boxed::Box<()>; // in scope 0 at a.rs:4:14: 4:15
let mut _4: std::boxed::Box<()>; // in scope 0 at a.rs:4:25: 4:26
let mut _5: isize; // in scope 0 at a.rs:6:1: 6:2
scope 1 {
debug x => _3; // in scope 1 at a.rs:4:14: 4:15
}
bb0: {
_2 = discriminant(_1); // bb0[0]: scope 0 at a.rs:3:9: 3:13
switchInt(move _2) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; // bb0[1]: scope 0 at a.rs:3:9: 3:13
}
bb1: {
StorageLive(_3); // bb1[0]: scope 0 at a.rs:4:14: 4:15
_3 = move ((_1 as Some).0: std::boxed::Box<()>); // bb1[1]: scope 0 at a.rs:4:14: 4:15
StorageLive(_4); // bb1[2]: scope 1 at a.rs:4:25: 4:26
_4 = move _3; // bb1[3]: scope 1 at a.rs:4:25: 4:26
((_0 as Some).0: std::boxed::Box<()>) = move _4; // bb1[4]: scope 1 at a.rs:4:20: 4:27
discriminant(_0) = 1; // bb1[5]: scope 1 at a.rs:4:20: 4:27
StorageDead(_4); // bb1[6]: scope 1 at a.rs:4:26: 4:27
StorageDead(_3); // bb1[7]: scope 0 at a.rs:4:27: 4:28
goto -> bb4; // bb1[8]: scope 0 at a.rs:2:5: 5:6
}
bb2: {
unreachable; // bb2[0]: scope 0 at a.rs:2:11: 2:12
}
bb3: {
discriminant(_0) = 0; // bb3[0]: scope 0 at a.rs:3:17: 3:21
goto -> bb4; // bb3[1]: scope 0 at a.rs:2:5: 5:6
}
bb4: {
_5 = discriminant(_1); // bb4[0]: scope 0 at a.rs:6:1: 6:2
return; // bb4[1]: scope 0 at a.rs:6:2: 6:2
}
}
The _5 = discriminant(_1);
doesn't have any effect.
(Labeling A-cranelift
because this prevents codegen of the goto -> bb4
like return
. Which may result in a few extra instructions being emitted to move registers and jump to the return block for cg_clif.)
@rustbot modify labels: +A-mir +A-mir-opt +A-cranelift