Skip to content

Commit 62ba1bf

Browse files
authored
Rollup merge of #73969 - davidtwco:issue-73914-checkedadd-temp-generator-interior, r=matthewjasper
mir: mark mir construction temporaries as internal Fixes #73914. This PR 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. r? @matthewjasper
2 parents ca5b64d + 1b747a0 commit 62ba1bf

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/librustc_mir_build/build/misc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1515
/// N.B., **No cleanup is scheduled for this temporary.** You should
1616
/// call `schedule_drop` once the temporary is initialized.
1717
crate fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
18-
let temp = self.local_decls.push(LocalDecl::new(ty, span));
18+
// Mark this local as internal to avoid temporaries with types not present in the
19+
// user's code resulting in ICEs from the generator transform.
20+
let temp = self.local_decls.push(LocalDecl::new(ty, span).internal());
1921
let place = Place::from(temp);
2022
debug!("temp: created temp {:?} with type {:?}", place, self.local_decls[temp].ty);
2123
place

src/test/ui/issue-73914.rs

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// build-pass
2+
// compile-flags:-Copt-level=0
3+
// edition:2018
4+
5+
struct S<T>(std::marker::PhantomData<T>);
6+
7+
impl<T> std::ops::Deref for S<T> {
8+
type Target = T;
9+
10+
fn deref(&self) -> &Self::Target {
11+
todo!()
12+
}
13+
}
14+
impl<T> std::ops::DerefMut for S<T> {
15+
fn deref_mut(&mut self) -> &mut Self::Target {
16+
todo!()
17+
}
18+
}
19+
20+
async fn new() -> S<u64> {
21+
todo!()
22+
}
23+
24+
async fn crash() {
25+
*new().await = 1 + 1;
26+
}
27+
28+
fn main() {
29+
let _ = crash();
30+
}

0 commit comments

Comments
 (0)