diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index 4ac3a268c9c33..089fb95966c42 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -1303,7 +1303,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } } CastKind::Transmute => { - if let MirPhase::Runtime(..) = self.body.phase { + if self.body.phase >= MirPhase::Analysis(AnalysisPhase::PostCleanup) { // Unlike `mem::transmute`, a MIR `Transmute` is well-formed // for any two `Sized` types, just potentially UB to run. @@ -1331,7 +1331,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { self.fail( location, format!( - "Transmute is not supported in non-runtime phase {:?}.", + "Transmute is not supported until Analysis(PostCleanup), but was used in {:?}.", self.body.phase ), ); diff --git a/tests/ui/mir/drop_in_async.rs b/tests/ui/mir/drop_in_async.rs new file mode 100644 index 0000000000000..97762f57377e7 --- /dev/null +++ b/tests/ui/mir/drop_in_async.rs @@ -0,0 +1,16 @@ +//@ run-pass +//@ compile-flags: --edition=2024 -Zvalidate-mir + +// async drops are elaborated earlier than non-async ones. +// See + +struct HasDrop; +impl Drop for HasDrop { + fn drop(&mut self) {} +} + +fn main() { + let _ = async { + vec![async { HasDrop }.await]; + }; +}