Skip to content

Commit

Permalink
Rollup merge of #72502 - RalfJung:generator-discr-ty, r=jonas-schievink
Browse files Browse the repository at this point in the history
fix discriminant type in generator transform

The generator transform assumed that the discriminant type is always `isize`, which is not correct, leading to [ICEs in Miri](https:/rust-lang/rust/pull/72419/files#r429543536) when some extra sanity checking got enabled.

r? @jonas-schievink @eddyb
  • Loading branch information
Dylan-DPC authored May 23, 2020
2 parents ee92ddf + b388f96 commit 1e79144
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl TransformVisitor<'tcx> {

// Create a statement which reads the discriminant into a temporary
fn get_discr(&self, body: &mut Body<'tcx>) -> (Statement<'tcx>, Place<'tcx>) {
let temp_decl = LocalDecl::new(self.tcx.types.isize, body.span).internal();
let temp_decl = LocalDecl::new(self.discr_ty, body.span).internal();
let local_decls_len = body.local_decls.push(temp_decl);
let temp = Place::from(local_decls_len);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn main::{{closure}}#0(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15:
let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:12:9: 12:14
let mut _7: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:18: 10:18
let mut _8: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
let mut _9: isize; // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
let mut _9: u32; // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
scope 1 {
debug _s => (((*_1) as variant#3).0: std::string::String); // in scope 1 at $DIR/generator-drop-cleanup.rs:11:13: 11:15
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:
let _8: (); // in scope 0 at $DIR/generator-tiny.rs:23:13: 23:21
let mut _9: (); // in scope 0 at $DIR/generator-tiny.rs:19:25: 19:25
let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
let mut _11: isize; // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
let mut _11: u32; // in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
scope 1 {
debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:20:13: 20:15
}
Expand Down

0 comments on commit 1e79144

Please sign in to comment.