Skip to content

Commit fe323d4

Browse files
committed
Don't run the ConstProp MIR pass on generators
This can cause cycles as `ConstProp` uses `layout_of` which, for generators, uses `optimized_mir` which runs `ConstProp`.
1 parent 72050c8 commit fe323d4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustc_mir/transform/const_prop.rs

+8
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
5757
return
5858
}
5959

60+
let is_generator = tcx.type_of(source.def_id()).is_generator();
61+
// FIXME(welseywiser) const prop doesn't work on generators because of query cycles
62+
// computing their layout.
63+
if is_generator {
64+
trace!("ConstProp skipped for generator {:?}", source.def_id());
65+
return
66+
}
67+
6068
trace!("ConstProp starting for {:?}", source.def_id());
6169

6270
// Steal some data we need from `body`.

0 commit comments

Comments
 (0)