diff --git a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
index 7976b65aae7b0..fbc8ee9b06c03 100644
--- a/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
+++ b/compiler/rustc_mir_transform/src/shim/async_destructor_ctor.rs
@@ -6,7 +6,7 @@ use rustc_middle::mir::{
     BasicBlock, BasicBlockData, Body, Local, LocalDecl, MirSource, Operand, Place, Rvalue,
     SourceInfo, Statement, StatementKind, Terminator, TerminatorKind,
 };
-use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt};
+use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, TypeVisitableExt};
 
 use super::*;
 use crate::patch::MirPatch;
@@ -121,9 +121,10 @@ pub(super) fn build_async_drop_shim<'tcx>(
         parent_args.as_coroutine().resume_ty(),
     )));
     body.phase = MirPhase::Runtime(RuntimePhase::Initial);
-    if !needs_async_drop {
+    if !needs_async_drop || drop_ty.references_error() {
         // Returning noop body for types without `need async drop`
-        // (or sync Drop in case of !`need async drop` && `need drop`)
+        // (or sync Drop in case of !`need async drop` && `need drop`).
+        // And also for error types.
         return body;
     }
 
diff --git a/tests/ui/async-await/async-drop/open-drop-error2.rs b/tests/ui/async-await/async-drop/open-drop-error2.rs
new file mode 100644
index 0000000000000..b2a7b68190ec1
--- /dev/null
+++ b/tests/ui/async-await/async-drop/open-drop-error2.rs
@@ -0,0 +1,21 @@
+//@compile-flags: -Zvalidate-mir -Zinline-mir=yes --crate-type=lib
+
+#![feature(async_drop)]
+#![allow(incomplete_features)]
+
+use std::{
+    future::{Future, async_drop_in_place},
+    pin::pin,
+    task::Context,
+};
+
+fn wrong() -> impl Sized {
+    //~^ ERROR: the size for values of type `str` cannot be known at compilation time
+    *"abc" // Doesn't implement Sized
+}
+fn weird(context: &mut Context<'_>) {
+    let mut e = wrong();
+    let h = unsafe { async_drop_in_place(&raw mut e) };
+    let i = pin!(h);
+    i.poll(context);
+}
diff --git a/tests/ui/async-await/async-drop/open-drop-error2.stderr b/tests/ui/async-await/async-drop/open-drop-error2.stderr
new file mode 100644
index 0000000000000..e849829b1c78b
--- /dev/null
+++ b/tests/ui/async-await/async-drop/open-drop-error2.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/open-drop-error2.rs:12:15
+   |
+LL | fn wrong() -> impl Sized {
+   |               ^^^^^^^^^^ doesn't have a size known at compile-time
+LL |
+LL |     *"abc" // Doesn't implement Sized
+   |     ------ return type was inferred to be `str` here
+   |
+   = help: the trait `Sized` is not implemented for `str`
+help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression
+   |
+LL -     *"abc" // Doesn't implement Sized
+LL +     "abc" // Doesn't implement Sized
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.