Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build pre-coroutine-transform coroutine body on error #117686

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions compiler/rustc_mir_build/src/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,17 +656,7 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
let args = args.as_coroutine();
let yield_ty = args.yield_ty();
let return_ty = args.return_ty();
let self_ty = Ty::new_adt(
tcx,
tcx.adt_def(tcx.lang_items().pin_type().unwrap()),
tcx.mk_args(&[Ty::new_mut_ref(tcx, tcx.lifetimes.re_erased, coroutine_ty).into()]),
);
let coroutine_state = Ty::new_adt(
tcx,
tcx.adt_def(tcx.lang_items().coroutine_state().unwrap()),
tcx.mk_args(&[yield_ty.into(), return_ty.into()]),
);
(vec![self_ty, args.resume_ty()], coroutine_state, Some(yield_ty))
(vec![coroutine_ty, args.resume_ty()], return_ty, Some(yield_ty))
}
dk => bug!("{:?} is not a body: {:?}", def_id, dk),
};
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/mir/build-async-error-body-correctly.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// edition: 2021

async fn asyncfn() {
let binding = match true {};
//~^ ERROR non-exhaustive patterns: type `bool` is non-empty
}

fn main() {}
17 changes: 17 additions & 0 deletions tests/ui/mir/build-async-error-body-correctly.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
error[E0004]: non-exhaustive patterns: type `bool` is non-empty
--> $DIR/build-async-error-body-correctly.rs:4:25
|
LL | let binding = match true {};
| ^^^^
|
= note: the matched value is of type `bool`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
LL ~ let binding = match true {
LL + _ => todo!(),
LL ~ };
|

error: aborting due to previous error

For more information about this error, try `rustc --explain E0004`.
Loading