Skip to content

Commit eec86ba

Browse files
authoredApr 10, 2020
Rollup merge of #70957 - oli-obk:lazy_repeat_length_eval_ice, r=matthewjasper
Normalize MIR locals' types for generator layout computation. fixes #70905
2 parents 4dfa73a + 8a03147 commit eec86ba

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎src/librustc_mir/transform/generator.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -721,15 +721,18 @@ fn compute_layout<'tcx>(
721721
_ => bug!(),
722722
};
723723

724+
let param_env = tcx.param_env(source.def_id());
725+
724726
for (local, decl) in body.local_decls.iter_enumerated() {
725727
// Ignore locals which are internal or not live
726728
if !live_locals.contains(local) || decl.internal {
727729
continue;
728730
}
731+
let decl_ty = tcx.normalize_erasing_regions(param_env, decl.ty);
729732

730733
// Sanity check that typeck knows about the type of locals which are
731734
// live across a suspension point
732-
if !allowed.contains(&decl.ty) && !allowed_upvars.contains(&decl.ty) {
735+
if !allowed.contains(&decl_ty) && !allowed_upvars.contains(&decl_ty) {
733736
span_bug!(
734737
body.span,
735738
"Broken MIR: generator contains type {} in MIR, \
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// check-pass
2+
// edition:2018
3+
// compile-flags: --crate-type=lib
4+
5+
pub async fn test() {
6+
const C: usize = 4;
7+
foo(&mut [0u8; C]).await;
8+
}
9+
10+
async fn foo(_: &mut [u8]) {}

0 commit comments

Comments
 (0)