Rollup merge of #70259 - wesleywiser:use_reveal_all, r=eddyb
Use Reveal::All in MIR optimizations Resolves some code review feedback in #67662. Fixes #68855 r? @eddyb
This commit is contained in:
commit
0d5b83df26
3 changed files with 68 additions and 18 deletions
64
src/test/mir-opt/const_prop/control-flow-simplification.rs
Normal file
64
src/test/mir-opt/const_prop/control-flow-simplification.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
// compile-flags: -Zmir-opt-level=1
|
||||
|
||||
trait NeedsDrop:Sized{
|
||||
const NEEDS:bool=std::mem::needs_drop::<Self>();
|
||||
}
|
||||
|
||||
impl<This> NeedsDrop for This{}
|
||||
|
||||
fn hello<T>(){
|
||||
if <bool>::NEEDS {
|
||||
panic!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
hello::<()>();
|
||||
hello::<Vec<()>>();
|
||||
}
|
||||
|
||||
// END RUST SOURCE
|
||||
// START rustc.hello.ConstProp.before.mir
|
||||
// let mut _0: ();
|
||||
// let mut _1: bool;
|
||||
// let mut _2: !;
|
||||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const <bool as NeedsDrop>::NEEDS;
|
||||
// switchInt(_1) -> [false: bb1, otherwise: bb2];
|
||||
// }
|
||||
// bb1: {
|
||||
// _0 = ();
|
||||
// StorageDead(_1);
|
||||
// return;
|
||||
// }
|
||||
// bb2: {
|
||||
// StorageLive(_2);
|
||||
// const std::rt::begin_panic::<&str>(const "explicit panic");
|
||||
// }
|
||||
// END rustc.hello.ConstProp.before.mir
|
||||
// START rustc.hello.ConstProp.after.mir
|
||||
// let mut _0: ();
|
||||
// let mut _1: bool;
|
||||
// let mut _2: !;
|
||||
// bb0: {
|
||||
// StorageLive(_1);
|
||||
// _1 = const false;
|
||||
// switchInt(const false) -> [false: bb1, otherwise: bb2];
|
||||
// }
|
||||
// bb1: {
|
||||
// _0 = ();
|
||||
// StorageDead(_1);
|
||||
// return;
|
||||
// }
|
||||
// bb2: {
|
||||
// StorageLive(_2);
|
||||
// const std::rt::begin_panic::<&str>(const "explicit panic");
|
||||
// }
|
||||
// END rustc.hello.ConstProp.after.mir
|
||||
// START rustc.hello.PreCodegen.before.mir
|
||||
// let mut _0: ();
|
||||
// bb0: {
|
||||
// return;
|
||||
// }
|
||||
// END rustc.hello.PreCodegen.before.mir
|
||||
Loading…
Add table
Add a link
Reference in a new issue