Skip to content

Commit a3aacb9

Browse files
authored
Unrolled build for rust-lang#117686
Rollup merge of rust-lang#117686 - compiler-errors:gen-body, r=wesleywiser Build pre-coroutine-transform coroutine body on error I was accidentally building the post-transform coroutine body, rather than the pre-transform coroutine body. There's no pinning expected here yet, and the return type isn't yet transformed into `CoroutineState`. Fixes rust-lang#117670
2 parents dd430bc + 0ba7d19 commit a3aacb9

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

compiler/rustc_mir_build/src/build/mod.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -656,17 +656,7 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
656656
let args = args.as_coroutine();
657657
let yield_ty = args.yield_ty();
658658
let return_ty = args.return_ty();
659-
let self_ty = Ty::new_adt(
660-
tcx,
661-
tcx.adt_def(tcx.lang_items().pin_type().unwrap()),
662-
tcx.mk_args(&[Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, coroutine_ty).into()]),
663-
);
664-
let coroutine_state = Ty::new_adt(
665-
tcx,
666-
tcx.adt_def(tcx.lang_items().coroutine_state().unwrap()),
667-
tcx.mk_args(&[yield_ty.into(), return_ty.into()]),
668-
);
669-
(vec![self_ty, args.resume_ty()], coroutine_state, Some(yield_ty))
659+
(vec![coroutine_ty, args.resume_ty()], return_ty, Some(yield_ty))
670660
}
671661
dk => bug!("{:?} is not a body: {:?}", def_id, dk),
672662
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// edition: 2021
2+
3+
async fn asyncfn() {
4+
let binding = match true {};
5+
//~^ ERROR non-exhaustive patterns: type `bool` is non-empty
6+
}
7+
8+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0004]: non-exhaustive patterns: type `bool` is non-empty
2+
--> $DIR/build-async-error-body-correctly.rs:4:25
3+
|
4+
LL | let binding = match true {};
5+
| ^^^^
6+
|
7+
= note: the matched value is of type `bool`
8+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
9+
|
10+
LL ~ let binding = match true {
11+
LL + _ => todo!(),
12+
LL ~ };
13+
|
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0004`.

0 commit comments

Comments
 (0)