Skip to content

Commit d35b23e

Browse files
Normalize generator-local types with unevaluated constants
1 parent cfa4ac6 commit d35b23e

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

compiler/rustc_mir_transform/src/generator.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,13 @@ fn sanitize_witness<'tcx>(
726726
saved_locals: &GeneratorSavedLocals,
727727
) {
728728
let did = body.source.def_id();
729-
let allowed_upvars = tcx.erase_regions(upvars);
729+
let param_env = tcx.param_env(did);
730+
731+
let allowed_upvars = tcx.normalize_erasing_regions(param_env, upvars);
730732
let allowed = match witness.kind() {
731-
&ty::GeneratorWitness(s) => tcx.erase_late_bound_regions(s),
733+
&ty::GeneratorWitness(interior_tys) => {
734+
tcx.normalize_erasing_late_bound_regions(param_env, interior_tys)
735+
}
732736
_ => {
733737
tcx.sess.delay_span_bug(
734738
body.span,
@@ -738,8 +742,6 @@ fn sanitize_witness<'tcx>(
738742
}
739743
};
740744

741-
let param_env = tcx.param_env(did);
742-
743745
for (local, decl) in body.local_decls.iter_enumerated() {
744746
// Ignore locals which are internal or not saved between yields.
745747
if !saved_locals.contains(local) || decl.internal {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// edition:2018
2+
// run-pass
3+
4+
#![allow(incomplete_features)]
5+
#![feature(generic_const_exprs)]
6+
#![allow(unused)]
7+
8+
fn main() {
9+
let x = test();
10+
}
11+
12+
fn concat<const A: usize, const B: usize>(a: [f32; A], b: [f32; B]) -> [f32; A + B] {
13+
todo!()
14+
}
15+
16+
async fn reverse<const A: usize>(x: [f32; A]) -> [f32; A] {
17+
todo!()
18+
}
19+
20+
async fn test() {
21+
let a = [0.0];
22+
let b = [1.0, 2.0];
23+
let ab = concat(a,b);
24+
let ba = reverse(ab).await;
25+
println!("{:?}", ba);
26+
}

0 commit comments

Comments
 (0)