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:
Mazdak Farrokhzad 2020-03-24 07:13:38 +01:00 committed by GitHub
commit 0d5b83df26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 18 deletions

View 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