Skip to content

Commit 9e0697f

Browse files
committed
CTFE: move target_{i, u}size_{min, max) to rustc_abi::TargetDataLayout
1 parent 8d504ea commit 9e0697f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/intptrcast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'mir, 'tcx> GlobalStateInner {
207207
.checked_add(max(size.bytes(), 1))
208208
.ok_or_else(|| err_exhaust!(AddressSpaceFull))?;
209209
// Even if `Size` didn't overflow, we might still have filled up the address space.
210-
if global_state.next_base_addr > ecx.target_usize_max() {
210+
if global_state.next_base_addr > ecx.data_layout().target_usize_max() {
211211
throw_exhaust!(AddressSpaceFull);
212212
}
213213
// Given that `next_base_addr` increases in each allocation, pushing the

src/shims/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use log::trace;
2121

2222
use rustc_middle::{mir, ty};
2323
use rustc_target::spec::abi::Abi;
24+
use rustc_target::abi::HasDataLayout as _;
2425

2526
use crate::*;
2627
use helpers::check_arg_count;
@@ -108,7 +109,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
108109
}
109110

110111
// Return error result (usize::MAX), and jump to caller.
111-
this.write_scalar(Scalar::from_target_usize(this.target_usize_max(), this), dest)?;
112+
let usize_max = this.data_layout().target_usize_max();
113+
this.write_scalar(Scalar::from_target_usize(usize_max, this), dest)?;
112114
this.go_to_block(ret);
113115
Ok(true)
114116
}

src/shims/unix/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use log::trace;
1212

1313
use rustc_data_structures::fx::FxHashMap;
1414
use rustc_middle::ty::TyCtxt;
15-
use rustc_target::abi::{Align, Size};
15+
use rustc_target::abi::{Align, Size, HasDataLayout as _};
1616

1717
use crate::shims::os_str::bytes_to_os_str;
1818
use crate::*;
@@ -753,7 +753,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
753753
// We cap the number of read bytes to the largest value that we are able to fit in both the
754754
// host's and target's `isize`. This saves us from having to handle overflows later.
755755
let count = count
756-
.min(u64::try_from(this.target_isize_max()).unwrap())
756+
.min(u64::try_from(this.data_layout().target_isize_max()).unwrap())
757757
.min(u64::try_from(isize::MAX).unwrap());
758758
let communicate = this.machine.communicate();
759759

@@ -807,7 +807,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
807807
// We cap the number of written bytes to the largest value that we are able to fit in both the
808808
// host's and target's `isize`. This saves us from having to handle overflows later.
809809
let count = count
810-
.min(u64::try_from(this.target_isize_max()).unwrap())
810+
.min(u64::try_from(this.data_layout().target_isize_max()).unwrap())
811811
.min(u64::try_from(isize::MAX).unwrap());
812812
let communicate = this.machine.communicate();
813813

0 commit comments

Comments
 (0)