mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Box AssertKind
This commit is contained in:
parent
dbba594575
commit
f08f903fa9
@ -138,7 +138,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
|
|||||||
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
|
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
|
||||||
self.consume_operand(location, cond);
|
self.consume_operand(location, cond);
|
||||||
use rustc_middle::mir::AssertKind;
|
use rustc_middle::mir::AssertKind;
|
||||||
if let AssertKind::BoundsCheck { len, index } = msg {
|
if let AssertKind::BoundsCheck { len, index } = &**msg {
|
||||||
self.consume_operand(location, len);
|
self.consume_operand(location, len);
|
||||||
self.consume_operand(location, index);
|
self.consume_operand(location, index);
|
||||||
}
|
}
|
||||||
|
@ -738,7 +738,7 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
|
|||||||
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
|
TerminatorKind::Assert { cond, expected: _, msg, target: _, unwind: _ } => {
|
||||||
self.consume_operand(loc, (cond, span), flow_state);
|
self.consume_operand(loc, (cond, span), flow_state);
|
||||||
use rustc_middle::mir::AssertKind;
|
use rustc_middle::mir::AssertKind;
|
||||||
if let AssertKind::BoundsCheck { len, index } = msg {
|
if let AssertKind::BoundsCheck { len, index } = &**msg {
|
||||||
self.consume_operand(loc, (len, span), flow_state);
|
self.consume_operand(loc, (len, span), flow_state);
|
||||||
self.consume_operand(loc, (index, span), flow_state);
|
self.consume_operand(loc, (index, span), flow_state);
|
||||||
}
|
}
|
||||||
|
@ -1404,7 +1404,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
|||||||
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
|
span_mirbug!(self, term, "bad Assert ({:?}, not bool", cond_ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let AssertKind::BoundsCheck { len, index } = msg {
|
if let AssertKind::BoundsCheck { len, index } = &**msg {
|
||||||
if len.ty(body, tcx) != tcx.types.usize {
|
if len.ty(body, tcx) != tcx.types.usize {
|
||||||
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
|
span_mirbug!(self, len, "bounds-check length non-usize {:?}", len)
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
|
|||||||
fx.bcx.switch_to_block(failure);
|
fx.bcx.switch_to_block(failure);
|
||||||
fx.bcx.ins().nop();
|
fx.bcx.ins().nop();
|
||||||
|
|
||||||
match msg {
|
match &**msg {
|
||||||
AssertKind::BoundsCheck { ref len, ref index } => {
|
AssertKind::BoundsCheck { ref len, ref index } => {
|
||||||
let len = codegen_operand(fx, len).load_scalar(fx);
|
let len = codegen_operand(fx, len).load_scalar(fx);
|
||||||
let index = codegen_operand(fx, index).load_scalar(fx);
|
let index = codegen_operand(fx, index).load_scalar(fx);
|
||||||
|
@ -3073,13 +3073,13 @@ mod size_asserts {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use rustc_data_structures::static_assert_size;
|
use rustc_data_structures::static_assert_size;
|
||||||
// tidy-alphabetical-start
|
// tidy-alphabetical-start
|
||||||
static_assert_size!(BasicBlockData<'_>, 144);
|
static_assert_size!(BasicBlockData<'_>, 136);
|
||||||
static_assert_size!(LocalDecl<'_>, 40);
|
static_assert_size!(LocalDecl<'_>, 40);
|
||||||
static_assert_size!(SourceScopeData<'_>, 72);
|
static_assert_size!(SourceScopeData<'_>, 72);
|
||||||
static_assert_size!(Statement<'_>, 32);
|
static_assert_size!(Statement<'_>, 32);
|
||||||
static_assert_size!(StatementKind<'_>, 16);
|
static_assert_size!(StatementKind<'_>, 16);
|
||||||
static_assert_size!(Terminator<'_>, 112);
|
static_assert_size!(Terminator<'_>, 104);
|
||||||
static_assert_size!(TerminatorKind<'_>, 96);
|
static_assert_size!(TerminatorKind<'_>, 88);
|
||||||
static_assert_size!(VarDebugInfo<'_>, 80);
|
static_assert_size!(VarDebugInfo<'_>, 80);
|
||||||
// tidy-alphabetical-end
|
// tidy-alphabetical-end
|
||||||
}
|
}
|
||||||
|
@ -651,7 +651,7 @@ pub enum TerminatorKind<'tcx> {
|
|||||||
Assert {
|
Assert {
|
||||||
cond: Operand<'tcx>,
|
cond: Operand<'tcx>,
|
||||||
expected: bool,
|
expected: bool,
|
||||||
msg: AssertMessage<'tcx>,
|
msg: Box<AssertMessage<'tcx>>,
|
||||||
target: BasicBlock,
|
target: BasicBlock,
|
||||||
unwind: UnwindAction,
|
unwind: UnwindAction,
|
||||||
},
|
},
|
||||||
|
@ -1172,7 +1172,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||||||
TerminatorKind::Assert {
|
TerminatorKind::Assert {
|
||||||
cond,
|
cond,
|
||||||
expected,
|
expected,
|
||||||
msg,
|
msg: Box::new(msg),
|
||||||
target: success_block,
|
target: success_block,
|
||||||
unwind: UnwindAction::Continue,
|
unwind: UnwindAction::Continue,
|
||||||
},
|
},
|
||||||
|
@ -224,10 +224,10 @@ fn insert_alignment_check<'tcx>(
|
|||||||
cond: Operand::Copy(is_ok),
|
cond: Operand::Copy(is_ok),
|
||||||
expected: true,
|
expected: true,
|
||||||
target: new_block,
|
target: new_block,
|
||||||
msg: AssertKind::MisalignedPointerDereference {
|
msg: Box::new(AssertKind::MisalignedPointerDereference {
|
||||||
required: Operand::Copy(alignment),
|
required: Operand::Copy(alignment),
|
||||||
found: Operand::Copy(addr),
|
found: Operand::Copy(addr),
|
||||||
},
|
}),
|
||||||
unwind: UnwindAction::Terminate,
|
unwind: UnwindAction::Terminate,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1150,7 +1150,7 @@ fn insert_panic_block<'tcx>(
|
|||||||
literal: ConstantKind::from_bool(tcx, false),
|
literal: ConstantKind::from_bool(tcx, false),
|
||||||
})),
|
})),
|
||||||
expected: true,
|
expected: true,
|
||||||
msg: message,
|
msg: Box::new(message),
|
||||||
target: assert_block,
|
target: assert_block,
|
||||||
unwind: UnwindAction::Continue,
|
unwind: UnwindAction::Continue,
|
||||||
};
|
};
|
||||||
|
@ -843,7 +843,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mir::TerminatorKind::Assert { ref msg, .. } => {
|
mir::TerminatorKind::Assert { ref msg, .. } => {
|
||||||
let lang_item = match msg {
|
let lang_item = match &**msg {
|
||||||
mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck,
|
mir::AssertKind::BoundsCheck { .. } => LangItem::PanicBoundsCheck,
|
||||||
_ => LangItem::Panic,
|
_ => LangItem::Panic,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user