Skip to content

Commit 9d795a6

Browse files
committed
Auto merge of rust-lang#111082 - saethlin:box-assertkind, r=saethlin
Box AssertKind r? `@nnethercote` this feels like your kind of thing I want to add a new variant to `AssertKind` that needs 3 operands, and that ends up breaking a bunch of size assertions. So... what if we go the opposite direction first; shrinking `AssertKind` by boxing it?
2 parents 98c33e4 + f08f903 commit 9d795a6

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

compiler/rustc_borrowck/src/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
138138
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
139139
self.consume_operand(location, cond);
140140
use rustc_middle::mir::AssertKind;
141-
if let AssertKind::BoundsCheck { len, index } = msg {
141+
if let AssertKind::BoundsCheck { len, index } = &**msg {
142142
self.consume_operand(location, len);
143143
self.consume_operand(location, index);
144144
}

compiler/rustc_borrowck/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
738738
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
739739
self.consume_operand(loc, (cond, span), flow_state);
740740
use rustc_middle::mir::AssertKind;
741-
if let AssertKind::BoundsCheck { len, index } = msg {
741+
if let AssertKind::BoundsCheck { len, index } = &**msg {
742742
self.consume_operand(loc, (len, span), flow_state);
743743
self.consume_operand(loc, (index, span), flow_state);
744744
}

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14041404
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
14051405
}
14061406

1407-
if let AssertKind::BoundsCheck { len, index } = msg {
1407+
if let AssertKind::BoundsCheck { len, index } = &**msg {
14081408
if len.ty(body, tcx) != tcx.types.usize {
14091409
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
14101410
}

compiler/rustc_codegen_cranelift/src/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
335335
fx.bcx.switch_to_block(failure);
336336
fx.bcx.ins().nop();
337337

338-
match msg {
338+
match &**msg {
339339
AssertKind::BoundsCheck { ref len, ref index } => {
340340
let len = codegen_operand(fx, len).load_scalar(fx);
341341
let index = codegen_operand(fx, index).load_scalar(fx);

compiler/rustc_middle/src/mir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3073,13 +3073,13 @@ mod size_asserts {
30733073
use super::*;
30743074
use rustc_data_structures::static_assert_size;
30753075
// tidy-alphabetical-start
3076-
static_assert_size!(BasicBlockData<'_>, 144);
3076+
static_assert_size!(BasicBlockData<'_>, 136);
30773077
static_assert_size!(LocalDecl<'_>, 40);
30783078
static_assert_size!(SourceScopeData<'_>, 72);
30793079
static_assert_size!(Statement<'_>, 32);
30803080
static_assert_size!(StatementKind<'_>, 16);
3081-
static_assert_size!(Terminator<'_>, 112);
3082-
static_assert_size!(TerminatorKind<'_>, 96);
3081+
static_assert_size!(Terminator<'_>, 104);
3082+
static_assert_size!(TerminatorKind<'_>, 88);
30833083
static_assert_size!(VarDebugInfo<'_>, 80);
30843084
// tidy-alphabetical-end
30853085
}

compiler/rustc_middle/src/mir/syntax.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ pub enum TerminatorKind<'tcx> {
651651
Assert {
652652
cond: Operand<'tcx>,
653653
expected: bool,
654-
msg: AssertMessage<'tcx>,
654+
msg: Box<AssertMessage<'tcx>>,
655655
target: BasicBlock,
656656
unwind: UnwindAction,
657657
},

compiler/rustc_mir_build/src/build/scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
11721172
TerminatorKind::Assert {
11731173
cond,
11741174
expected,
1175-
msg,
1175+
msg: Box::new(msg),
11761176
target: success_block,
11771177
unwind: UnwindAction::Continue,
11781178
},

compiler/rustc_mir_transform/src/check_alignment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ fn insert_alignment_check<'tcx>(
224224
cond: Operand::Copy(is_ok),
225225
expected: true,
226226
target: new_block,
227-
msg: AssertKind::MisalignedPointerDereference {
227+
msg: Box::new(AssertKind::MisalignedPointerDereference {
228228
required: Operand::Copy(alignment),
229229
found: Operand::Copy(addr),
230-
},
230+
}),
231231
unwind: UnwindAction::Terminate,
232232
},
233233
});

compiler/rustc_mir_transform/src/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ fn insert_panic_block<'tcx>(
11501150
literal: ConstantKind::from_bool(tcx, false),
11511151
})),
11521152
expected: true,
1153-
msg: message,
1153+
msg: Box::new(message),
11541154
target: assert_block,
11551155
unwind: UnwindAction::Continue,
11561156
};

compiler/rustc_monomorphize/src/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
843843
}
844844
}
845845
mir::TerminatorKind::Assert { ref msg, .. } => {
846-
let lang_item = match msg {
846+
let lang_item = match &**msg {
847847
mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck,
848848
_ => LangItem::Panic,
849849
};

0 commit comments

Comments
 (0)