Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok(true)
}

fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
crate fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... of it's (semi-)public, maybe it should have a doc comment?

Also for consistency, terminator should probably get the same treatment.

info!("{:?}", stmt);
self.set_span(stmt.source_info.span);

Expand Down
4 changes: 4 additions & 0 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
match f(self) {
Ok(val) => Some(val),
Err(error) => {
trace!("InterpCx operation failed: {:?}", error);
// Some errors shouldn't come up because creating them causes
// an allocation, which we should avoid. When that happens,
// dedicated error variants should be introduced instead.
Expand Down Expand Up @@ -906,6 +907,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
}
} else {
match statement.kind {
StatementKind::SetDiscriminant { .. } => {
self.use_ecx(|this| this.ecx.statement(statement));
}
StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => {
let frame = self.ecx.frame_mut();
frame.locals[local].value =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@
// + literal: Const { ty: u8, val: Value(Scalar(0x00)) }
discriminant(_1) = 0; // scope 0 at $DIR/simplify-arm-identity.rs:18:18: 18:29
StorageLive(_2); // scope 1 at $DIR/simplify-arm-identity.rs:19:18: 22:6
_3 = discriminant(_1); // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20
switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20
_3 = const 0isize; // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20
// ty::Const
// + ty: isize
// + val: Value(Scalar(0x0000000000000000))
// mir::Constant
// + span: $DIR/simplify-arm-identity.rs:20:9: 20:20
// + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000000)) }
goto -> bb3; // scope 1 at $DIR/simplify-arm-identity.rs:20:9: 20:20
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ fn change_loop_body() -> () {
let mut _0: (); // return place in scope 0 at $DIR/while_let_loops.rs:4:27: 4:27
let mut _1: i32; // in scope 0 at $DIR/while_let_loops.rs:5:9: 5:15
let mut _2: std::option::Option<u32>; // in scope 0 at $DIR/while_let_loops.rs:6:28: 6:32
let mut _3: isize; // in scope 0 at $DIR/while_let_loops.rs:6:15: 6:25
scope 1 {
debug _x => _1; // in scope 1 at $DIR/while_let_loops.rs:5:9: 5:15
}
Expand All @@ -20,44 +19,13 @@ fn change_loop_body() -> () {
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
StorageLive(_2); // scope 1 at $DIR/while_let_loops.rs:6:28: 6:32
discriminant(_2) = 0; // scope 1 at $DIR/while_let_loops.rs:6:28: 6:32
_3 = discriminant(_2); // scope 1 at $DIR/while_let_loops.rs:6:15: 6:25
switchInt(move _3) -> [1isize: bb2, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:6:15: 6:25
}

bb1: {
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:6:5: 9:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:6:5: 9:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:6:5: 9:6
}

bb2: {
switchInt(((_2 as Some).0: u32)) -> [0u32: bb3, otherwise: bb1]; // scope 1 at $DIR/while_let_loops.rs:6:20: 6:24
}

bb3: {
_1 = const 1i32; // scope 1 at $DIR/while_let_loops.rs:7:9: 7:15
// ty::Const
// + ty: i32
// + val: Value(Scalar(0x00000001))
// mir::Constant
// + span: $DIR/while_let_loops.rs:7:14: 7:15
// + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) }
_0 = const (); // scope 1 at $DIR/while_let_loops.rs:8:9: 8:14
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/while_let_loops.rs:8:9: 8:14
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
goto -> bb4; // scope 1 at $DIR/while_let_loops.rs:8:9: 8:14
}

bb4: {
StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:9:5: 9:6
StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:10:1: 10:2
return; // scope 0 at $DIR/while_let_loops.rs:10:2: 10:2
Expand Down