Skip to content

Commit 9d95c8b

Browse files
compiler: Factor rustc_target::abi out of const_eval
1 parent 11c48be commit 9d95c8b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

compiler/rustc_const_eval/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
either = "1"
9+
rustc_abi = { path = "../rustc_abi" }
910
rustc_apfloat = "0.2.0"
1011
rustc_ast = { path = "../rustc_ast" }
1112
rustc_attr = { path = "../rustc_attr" }

compiler/rustc_const_eval/src/interpret/operand.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
use std::assert_matches::assert_matches;
55

66
use either::{Either, Left, Right};
7+
use rustc_abi as abi;
8+
use rustc_abi::{Abi, HasDataLayout, Size};
79
use rustc_hir::def::Namespace;
810
use rustc_middle::mir::interpret::ScalarSizeMismatch;
911
use rustc_middle::ty::layout::{HasParamEnv, HasTyCtxt, LayoutOf, TyAndLayout};
1012
use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter};
1113
use rustc_middle::ty::{ConstInt, ScalarInt, Ty, TyCtxt};
1214
use rustc_middle::{bug, mir, span_bug, ty};
13-
use rustc_target::abi::{self, Abi, HasDataLayout, Size};
1415
use tracing::trace;
1516

1617
use super::{
@@ -117,7 +118,7 @@ impl<Prov: Provenance> Immediate<Prov> {
117118
match (self, abi) {
118119
(Immediate::Scalar(scalar), Abi::Scalar(s)) => {
119120
assert_eq!(scalar.size(), s.size(cx), "{msg}: scalar value has wrong size");
120-
if !matches!(s.primitive(), abi::Pointer(..)) {
121+
if !matches!(s.primitive(), abi::Primitive::Pointer(..)) {
121122
// This is not a pointer, it should not carry provenance.
122123
assert!(
123124
matches!(scalar, Scalar::Int(..)),
@@ -131,7 +132,7 @@ impl<Prov: Provenance> Immediate<Prov> {
131132
a.size(cx),
132133
"{msg}: first component of scalar pair has wrong size"
133134
);
134-
if !matches!(a.primitive(), abi::Pointer(..)) {
135+
if !matches!(a.primitive(), abi::Primitive::Pointer(..)) {
135136
assert!(
136137
matches!(a_val, Scalar::Int(..)),
137138
"{msg}: first component of scalar pair should be an integer, but has provenance"
@@ -142,7 +143,7 @@ impl<Prov: Provenance> Immediate<Prov> {
142143
b.size(cx),
143144
"{msg}: second component of scalar pair has wrong size"
144145
);
145-
if !matches!(b.primitive(), abi::Pointer(..)) {
146+
if !matches!(b.primitive(), abi::Primitive::Pointer(..)) {
146147
assert!(
147148
matches!(b_val, Scalar::Int(..)),
148149
"{msg}: second component of scalar pair should be an integer, but has provenance"
@@ -572,7 +573,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
572573
assert_eq!(size, mplace.layout.size, "abi::Scalar size does not match layout size");
573574
let scalar = alloc.read_scalar(
574575
alloc_range(Size::ZERO, size),
575-
/*read_provenance*/ matches!(s, abi::Pointer(_)),
576+
/*read_provenance*/ matches!(s, abi::Primitive::Pointer(_)),
576577
)?;
577578
Some(ImmTy::from_scalar(scalar, mplace.layout))
578579
}
@@ -588,11 +589,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
588589
assert!(b_offset.bytes() > 0); // in `operand_field` we use the offset to tell apart the fields
589590
let a_val = alloc.read_scalar(
590591
alloc_range(Size::ZERO, a_size),
591-
/*read_provenance*/ matches!(a, abi::Pointer(_)),
592+
/*read_provenance*/ matches!(a, abi::Primitive::Pointer(_)),
592593
)?;
593594
let b_val = alloc.read_scalar(
594595
alloc_range(b_offset, b_size),
595-
/*read_provenance*/ matches!(b, abi::Pointer(_)),
596+
/*read_provenance*/ matches!(b, abi::Primitive::Pointer(_)),
596597
)?;
597598
Some(ImmTy::from_immediate(Immediate::ScalarPair(a_val, b_val), mplace.layout))
598599
}

0 commit comments

Comments
 (0)