about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-11-07 21:14:38 +0000
committerMichael Goulet <michael@errs.io>2023-11-07 21:14:43 +0000
commit0ba7d19769c068729761eba72e779b53101a19bc (patch)
tree84c5e4cf8008a788fceb7ba6e99ebc09694219f3
parent9bd71afb90c2a6e0348cdd4a2b10a3bf39908f19 (diff)
downloadrust-0ba7d19769c068729761eba72e779b53101a19bc.tar.gz
rust-0ba7d19769c068729761eba72e779b53101a19bc.zip
Build pre-coroutine-transform coroutine body
-rw-r--r--compiler/rustc_mir_build/src/build/mod.rs12
-rw-r--r--tests/ui/mir/build-async-error-body-correctly.rs8
-rw-r--r--tests/ui/mir/build-async-error-body-correctly.stderr17
3 files changed, 26 insertions, 11 deletions
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs
index 7c729016521..886d805454d 100644
--- a/compiler/rustc_mir_build/src/build/mod.rs
+++ b/compiler/rustc_mir_build/src/build/mod.rs
@@ -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),
     };
diff --git a/tests/ui/mir/build-async-error-body-correctly.rs b/tests/ui/mir/build-async-error-body-correctly.rs
new file mode 100644
index 00000000000..1787f80c07e
--- /dev/null
+++ b/tests/ui/mir/build-async-error-body-correctly.rs
@@ -0,0 +1,8 @@
+// edition: 2021
+
+async fn asyncfn() {
+    let binding = match true {};
+    //~^ ERROR non-exhaustive patterns: type `bool` is non-empty
+}
+
+fn main() {}
diff --git a/tests/ui/mir/build-async-error-body-correctly.stderr b/tests/ui/mir/build-async-error-body-correctly.stderr
new file mode 100644
index 00000000000..3d18c249afe
--- /dev/null
+++ b/tests/ui/mir/build-async-error-body-correctly.stderr
@@ -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`.