about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-04-09 16:48:36 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-04-09 16:48:36 +0200
commit8a03147f224369f96c2a826bc2dcbde3a6be1f10 (patch)
tree2a9dab30b7463755569d83a06f7ea461bb234fd6
parent11f6096a9ef6ad52de2956f4d2df200de7617077 (diff)
downloadrust-8a03147f224369f96c2a826bc2dcbde3a6be1f10.tar.gz
rust-8a03147f224369f96c2a826bc2dcbde3a6be1f10.zip
Normalize MIR locals' types for generator layout computation.
-rw-r--r--src/librustc_mir/transform/generator.rs5
-rw-r--r--src/test/ui/repeat_count_const_in_async_fn.rs10
2 files changed, 14 insertions, 1 deletions
diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs
index 53eec1f6dc3..ca596f63393 100644
--- a/src/librustc_mir/transform/generator.rs
+++ b/src/librustc_mir/transform/generator.rs
@@ -720,15 +720,18 @@ fn compute_layout<'tcx>(
         _ => bug!(),
     };
 
+    let param_env = tcx.param_env(source.def_id());
+
     for (local, decl) in body.local_decls.iter_enumerated() {
         // Ignore locals which are internal or not live
         if !live_locals.contains(local) || decl.internal {
             continue;
         }
+        let decl_ty = tcx.normalize_erasing_regions(param_env, decl.ty);
 
         // Sanity check that typeck knows about the type of locals which are
         // live across a suspension point
-        if !allowed.contains(&decl.ty) && !allowed_upvars.contains(&decl.ty) {
+        if !allowed.contains(&decl_ty) && !allowed_upvars.contains(&decl_ty) {
             span_bug!(
                 body.span,
                 "Broken MIR: generator contains type {} in MIR, \
diff --git a/src/test/ui/repeat_count_const_in_async_fn.rs b/src/test/ui/repeat_count_const_in_async_fn.rs
new file mode 100644
index 00000000000..ebabc3fbf10
--- /dev/null
+++ b/src/test/ui/repeat_count_const_in_async_fn.rs
@@ -0,0 +1,10 @@
+// check-pass
+// edition:2018
+// compile-flags: --crate-type=lib
+
+pub async fn test() {
+    const C: usize = 4;
+    foo(&mut [0u8; C]).await;
+}
+
+async fn foo(_: &mut [u8]) {}