diff --git a/src/librustc_mir_build/build/misc.rs b/src/librustc_mir_build/build/misc.rs index e8933ff8aa749..29651d9bc663a 100644 --- a/src/librustc_mir_build/build/misc.rs +++ b/src/librustc_mir_build/build/misc.rs @@ -15,7 +15,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// N.B., **No cleanup is scheduled for this temporary.** You should /// call `schedule_drop` once the temporary is initialized. crate fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> { - let temp = self.local_decls.push(LocalDecl::new(ty, span)); + // Mark this local as internal to avoid temporaries with types not present in the + // user's code resulting in ICEs from the generator transform. + let temp = self.local_decls.push(LocalDecl::new(ty, span).internal()); let place = Place::from(temp); debug!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty); place diff --git a/src/test/ui/issue-73914.rs b/src/test/ui/issue-73914.rs new file mode 100644 index 0000000000000..1e99faaded4ef --- /dev/null +++ b/src/test/ui/issue-73914.rs @@ -0,0 +1,30 @@ +// build-pass +// compile-flags:-Copt-level=0 +// edition:2018 + +struct S(std::marker::PhantomData); + +impl std::ops::Deref for S { + type Target = T; + + fn deref(&self) -> &Self::Target { + todo!() + } +} +impl std::ops::DerefMut for S { + fn deref_mut(&mut self) -> &mut Self::Target { + todo!() + } +} + +async fn new() -> S { + todo!() +} + +async fn crash() { + *new().await = 1 + 1; +} + +fn main() { + let _ = crash(); +}