Skip to content

Commit 8b18860

Browse files
committed
A MIR transform that checks pointers are aligned
1 parent 7ac6cc9 commit 8b18860

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/base.rs

+12
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,18 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
379379
source_info.span,
380380
);
381381
}
382+
AssertKind::MisalignedPointerDereference { ref required, ref found } => {
383+
let required = codegen_operand(fx, required).load_scalar(fx);
384+
let found = codegen_operand(fx, found).load_scalar(fx);
385+
let location = fx.get_caller_location(source_info).load_scalar(fx);
386+
387+
codegen_panic_inner(
388+
fx,
389+
rustc_hir::LangItem::PanicBoundsCheck,
390+
&[required, found, location],
391+
source_info.span,
392+
);
393+
}
382394
_ => {
383395
let msg_str = msg.description();
384396
codegen_panic(fx, msg_str, source_info);

0 commit comments

Comments
 (0)