Skip to content

Commit ed7a4ad

Browse files
committed
32 bit platforms don't have 64 bit pointers
1 parent eac3099 commit ed7a4ad

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_mir/src/const_eval/eval_queries.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::ty::print::with_no_trimmed_paths;
1414
use rustc_middle::ty::{self, subst::Subst, TyCtxt};
1515
use rustc_span::source_map::Span;
1616
use rustc_target::abi::{Abi, LayoutOf};
17-
use std::convert::{TryFrom, TryInto};
17+
use std::convert::TryInto;
1818

1919
pub fn note_on_undefined_behavior_error() -> &'static str {
2020
"The rules on what exactly is undefined behavior aren't clear, \
@@ -140,7 +140,8 @@ pub(super) fn op_to_const<'tcx>(
140140
Scalar::Raw(int) => {
141141
assert!(mplace.layout.is_zst());
142142
assert_eq!(
143-
u64::try_from(int).unwrap() % mplace.layout.align.abi.bytes(),
143+
int.assert_bits(ecx.tcx.data_layout.pointer_size)
144+
% u128::from(mplace.layout.align.abi.bytes()),
144145
0,
145146
"this MPlaceTy must come from a validated constant, thus we can assume the \
146147
alignment is correct",

0 commit comments

Comments
 (0)