diff options
| author | David Wood <david@davidtw.co> | 2020-07-02 16:20:59 +0100 |
|---|---|---|
| committer | David Wood <david@davidtw.co> | 2020-07-02 16:20:59 +0100 |
| commit | 1b747a030f2dc1eba63f50f2c5f43938538e0c6a (patch) | |
| tree | ba213b7f10641e9c5a8109d017271a93fb36c242 | |
| parent | 9491f18c5de3ff1c4bf9c3fdacf52d9859e26f7c (diff) | |
| download | rust-1b747a030f2dc1eba63f50f2c5f43938538e0c6a.tar.gz rust-1b747a030f2dc1eba63f50f2c5f43938538e0c6a.zip | |
mir: mark mir construction temporaries as internal
This commit marks temporaries from MIR construction as internal such that they are skipped in `sanitize_witness` (where each MIR local is checked to have been contained within the generator interior computed during typeck). This resolves an ICE whereby the construction of checked addition introduced a `(u64, bool)` temporary which was not in the HIR and thus not in the generator interior. Signed-off-by: David Wood <david@davidtw.co>
| -rw-r--r-- | src/librustc_mir_build/build/misc.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/issue-73914.rs | 30 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/librustc_mir_build/build/misc.rs b/src/librustc_mir_build/build/misc.rs index e8933ff8aa7..29651d9bc66 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 00000000000..1e99faaded4 --- /dev/null +++ b/src/test/ui/issue-73914.rs @@ -0,0 +1,30 @@ +// build-pass +// compile-flags:-Copt-level=0 +// edition:2018 + +struct S<T>(std::marker::PhantomData<T>); + +impl<T> std::ops::Deref for S<T> { + type Target = T; + + fn deref(&self) -> &Self::Target { + todo!() + } +} +impl<T> std::ops::DerefMut for S<T> { + fn deref_mut(&mut self) -> &mut Self::Target { + todo!() + } +} + +async fn new() -> S<u64> { + todo!() +} + +async fn crash() { + *new().await = 1 + 1; +} + +fn main() { + let _ = crash(); +} |
