Skip to content

Commit 4f40511

Browse files
committed
Resolve worsened debug build codegen
1 parent 38114ff commit 4f40511

File tree

2 files changed

+65
-8
lines changed

2 files changed

+65
-8
lines changed

src/librustc_mir/transform/const_prop.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
324324
) -> ConstPropagator<'mir, 'tcx> {
325325
let def_id = source.def_id();
326326
let substs = &InternalSubsts::identity_for_item(tcx, def_id);
327-
let mut param_env = tcx.param_env(def_id);
328-
329-
// If we're evaluating inside a monomorphic function, then use `Reveal::All` because
330-
// we want to see the same instances that codegen will see. This allows us to `resolve()`
331-
// specializations.
332-
if !substs.needs_subst() {
333-
param_env = param_env.with_reveal_all();
334-
}
327+
let param_env = tcx.param_env(def_id).with_reveal_all();
335328

336329
let span = tcx.def_span(def_id);
337330
let mut ecx = InterpCx::new(tcx.at(span), param_env, ConstPropMachine, ());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// compile-flags: -Zmir-opt-level=1
2+
3+
trait NeedsDrop:Sized{
4+
const NEEDS:bool=std::mem::needs_drop::<Self>();
5+
}
6+
7+
impl<This> NeedsDrop for This{}
8+
9+
fn hello<T>(){
10+
if <bool>::NEEDS {
11+
panic!()
12+
}
13+
}
14+
15+
pub fn main() {
16+
hello::<()>();
17+
hello::<Vec<()>>();
18+
}
19+
20+
// END RUST SOURCE
21+
// START rustc.hello.ConstProp.before.mir
22+
// let mut _0: ();
23+
// let mut _1: bool;
24+
// let mut _2: !;
25+
// bb0: {
26+
// StorageLive(_1);
27+
// _1 = const <bool as NeedsDrop>::NEEDS;
28+
// switchInt(_1) -> [false: bb1, otherwise: bb2];
29+
// }
30+
// bb1: {
31+
// _0 = ();
32+
// StorageDead(_1);
33+
// return;
34+
// }
35+
// bb2: {
36+
// StorageLive(_2);
37+
// const std::rt::begin_panic::<&str>(const "explicit panic");
38+
// }
39+
// END rustc.hello.ConstProp.before.mir
40+
// START rustc.hello.ConstProp.after.mir
41+
// let mut _0: ();
42+
// let mut _1: bool;
43+
// let mut _2: !;
44+
// bb0: {
45+
// StorageLive(_1);
46+
// _1 = const false;
47+
// switchInt(const false) -> [false: bb1, otherwise: bb2];
48+
// }
49+
// bb1: {
50+
// _0 = ();
51+
// StorageDead(_1);
52+
// return;
53+
// }
54+
// bb2: {
55+
// StorageLive(_2);
56+
// const std::rt::begin_panic::<&str>(const "explicit panic");
57+
// }
58+
// END rustc.hello.ConstProp.after.mir
59+
// START rustc.hello.PreCodegen.before.mir
60+
// let mut _0: ();
61+
// bb0: {
62+
// return;
63+
// }
64+
// END rustc.hello.PreCodegen.before.mir

0 commit comments

Comments
 (0)