Skip to content

Commit 88c25f6

Browse files
committed
Auto merge of #147782 - matthiaskrgr:rollup-9728xqu, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang/rust#144438 (Guard HIR lowered contracts with `contract_checks`) - rust-lang/rust#147000 (std: Add Motor OS std library port) - rust-lang/rust#147576 (Fix ICE on offsetted ZST pointer) - rust-lang/rust#147732 (remove duplicate inline macro) - rust-lang/rust#147738 (Don't highlight `let` expressions as having type `bool` in let-chain error messages) - rust-lang/rust#147744 (miri subtree update) - rust-lang/rust#147751 (Use `bit_set::Word` in a couple more places.) - rust-lang/rust#147752 (style-guide: fix typo for empty struct advice) - rust-lang/rust#147773 (`is_ascii` on an empty string or slice returns true) r? `@ghost` `@rustbot` modify labels: rollup
2 parents eb1d1ab + 15d4695 commit 88c25f6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/common.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_codegen_ssa::traits::{
55
BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods,
66
};
77
use rustc_middle::mir::Mutability;
8-
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
8+
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, PointerArithmetic, Scalar};
99
use rustc_middle::ty::layout::LayoutOf;
1010

1111
use crate::context::CodegenCx;
@@ -247,8 +247,8 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
247247
// This avoids generating a zero-sized constant value and actually needing a
248248
// real address at runtime.
249249
if alloc.inner().len() == 0 {
250-
assert_eq!(offset.bytes(), 0);
251-
let val = self.const_usize(alloc.inner().align.bytes());
250+
let val = alloc.inner().align.bytes().wrapping_add(offset.bytes());
251+
let val = self.const_usize(self.tcx.truncate_to_target_usize(val));
252252
return if matches!(layout.primitive(), Pointer(_)) {
253253
self.context.new_cast(None, val, ty)
254254
} else {

0 commit comments

Comments
 (0)