Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit df4d717

Browse files
committed
s/Scalar::Raw/Scalar::Int
1 parent 3a79708 commit df4d717

File tree

13 files changed

+48
-48
lines changed

13 files changed

+48
-48
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub(crate) fn codegen_const_value<'tcx>(
186186
}
187187

188188
match x {
189-
Scalar::Raw(int) => {
189+
Scalar::Int(int) => {
190190
CValue::const_val(fx, layout, int)
191191
}
192192
Scalar::Ptr(ptr) => {

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,11 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
230230
fn scalar_to_backend(&self, cv: Scalar, layout: &abi::Scalar, llty: &'ll Type) -> &'ll Value {
231231
let bitsize = if layout.is_bool() { 1 } else { layout.value.size(self).bits() };
232232
match cv {
233-
Scalar::Raw(ScalarInt::ZST) => {
233+
Scalar::Int(ScalarInt::ZST) => {
234234
assert_eq!(0, layout.value.size(self).bytes());
235235
self.const_undef(self.type_ix(0))
236236
}
237-
Scalar::Raw(int) => {
237+
Scalar::Int(int) => {
238238
let data = int.assert_bits(layout.value.size(self));
239239
let llval = self.const_uint_big(self.type_ix(bitsize), data);
240240
if layout.value == Pointer {

compiler/rustc_middle/src/mir/interpret/value.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'tcx> ConstValue<'tcx> {
103103
#[derive(HashStable)]
104104
pub enum Scalar<Tag = ()> {
105105
/// The raw bytes of a simple value.
106-
Raw(ScalarInt),
106+
Int(ScalarInt),
107107

108108
/// A pointer into an `Allocation`. An `Allocation` in the `memory` module has a list of
109109
/// relocations, but a `Scalar` is only large enough to contain one, so we just represent the
@@ -120,7 +120,7 @@ impl<Tag: fmt::Debug> fmt::Debug for Scalar<Tag> {
120120
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
121121
match self {
122122
Scalar::Ptr(ptr) => write!(f, "{:?}", ptr),
123-
Scalar::Raw(int) => write!(f, "{:?}", int),
123+
Scalar::Int(int) => write!(f, "{:?}", int),
124124
}
125125
}
126126
}
@@ -129,7 +129,7 @@ impl<Tag: fmt::Debug> fmt::Display for Scalar<Tag> {
129129
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
130130
match self {
131131
Scalar::Ptr(ptr) => write!(f, "pointer to {}", ptr),
132-
Scalar::Raw { .. } => fmt::Debug::fmt(self, f),
132+
Scalar::Int { .. } => fmt::Debug::fmt(self, f),
133133
}
134134
}
135135
}
@@ -156,7 +156,7 @@ impl Scalar<()> {
156156
pub fn with_tag<Tag>(self, new_tag: Tag) -> Scalar<Tag> {
157157
match self {
158158
Scalar::Ptr(ptr) => Scalar::Ptr(ptr.with_tag(new_tag)),
159-
Scalar::Raw(int) => Scalar::Raw(int),
159+
Scalar::Int(int) => Scalar::Int(int),
160160
}
161161
}
162162
}
@@ -169,18 +169,18 @@ impl<'tcx, Tag> Scalar<Tag> {
169169
pub fn erase_tag(self) -> Scalar {
170170
match self {
171171
Scalar::Ptr(ptr) => Scalar::Ptr(ptr.erase_tag()),
172-
Scalar::Raw(int) => Scalar::Raw(int),
172+
Scalar::Int(int) => Scalar::Int(int),
173173
}
174174
}
175175

176176
#[inline]
177177
pub fn null_ptr(cx: &impl HasDataLayout) -> Self {
178-
Scalar::Raw(ScalarInt::null(cx.data_layout().pointer_size))
178+
Scalar::Int(ScalarInt::null(cx.data_layout().pointer_size))
179179
}
180180

181181
#[inline]
182182
pub fn zst() -> Self {
183-
Scalar::Raw(ScalarInt::zst())
183+
Scalar::Int(ScalarInt::zst())
184184
}
185185

186186
#[inline(always)]
@@ -191,7 +191,7 @@ impl<'tcx, Tag> Scalar<Tag> {
191191
f_ptr: impl FnOnce(Pointer<Tag>) -> InterpResult<'tcx, Pointer<Tag>>,
192192
) -> InterpResult<'tcx, Self> {
193193
match self {
194-
Scalar::Raw(int) => Ok(Scalar::Raw(int.ptr_sized_op(dl, f_int)?)),
194+
Scalar::Int(int) => Ok(Scalar::Int(int.ptr_sized_op(dl, f_int)?)),
195195
Scalar::Ptr(ptr) => Ok(Scalar::Ptr(f_ptr(ptr)?)),
196196
}
197197
}
@@ -232,17 +232,17 @@ impl<'tcx, Tag> Scalar<Tag> {
232232

233233
#[inline]
234234
pub fn from_bool(b: bool) -> Self {
235-
Scalar::Raw(b.into())
235+
Scalar::Int(b.into())
236236
}
237237

238238
#[inline]
239239
pub fn from_char(c: char) -> Self {
240-
Scalar::Raw(c.into())
240+
Scalar::Int(c.into())
241241
}
242242

243243
#[inline]
244244
pub fn try_from_uint(i: impl Into<u128>, size: Size) -> Option<Self> {
245-
ScalarInt::try_from_uint(i, size).map(Scalar::Raw)
245+
ScalarInt::try_from_uint(i, size).map(Scalar::Int)
246246
}
247247

248248
#[inline]
@@ -254,22 +254,22 @@ impl<'tcx, Tag> Scalar<Tag> {
254254

255255
#[inline]
256256
pub fn from_u8(i: u8) -> Self {
257-
Scalar::Raw(i.into())
257+
Scalar::Int(i.into())
258258
}
259259

260260
#[inline]
261261
pub fn from_u16(i: u16) -> Self {
262-
Scalar::Raw(i.into())
262+
Scalar::Int(i.into())
263263
}
264264

265265
#[inline]
266266
pub fn from_u32(i: u32) -> Self {
267-
Scalar::Raw(i.into())
267+
Scalar::Int(i.into())
268268
}
269269

270270
#[inline]
271271
pub fn from_u64(i: u64) -> Self {
272-
Scalar::Raw(i.into())
272+
Scalar::Int(i.into())
273273
}
274274

275275
#[inline]
@@ -279,7 +279,7 @@ impl<'tcx, Tag> Scalar<Tag> {
279279

280280
#[inline]
281281
pub fn try_from_int(i: impl Into<i128>, size: Size) -> Option<Self> {
282-
ScalarInt::try_from_int(i, size).map(Scalar::Raw)
282+
ScalarInt::try_from_int(i, size).map(Scalar::Int)
283283
}
284284

285285
#[inline]
@@ -316,12 +316,12 @@ impl<'tcx, Tag> Scalar<Tag> {
316316

317317
#[inline]
318318
pub fn from_f32(f: Single) -> Self {
319-
Scalar::Raw(f.into())
319+
Scalar::Int(f.into())
320320
}
321321

322322
#[inline]
323323
pub fn from_f64(f: Double) -> Self {
324-
Scalar::Raw(f.into())
324+
Scalar::Int(f.into())
325325
}
326326

327327
/// This is very rarely the method you want! You should dispatch on the type
@@ -336,7 +336,7 @@ impl<'tcx, Tag> Scalar<Tag> {
336336
) -> Result<u128, Pointer<Tag>> {
337337
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
338338
match self {
339-
Scalar::Raw(int) => Ok(int.assert_bits(target_size)),
339+
Scalar::Int(int) => Ok(int.assert_bits(target_size)),
340340
Scalar::Ptr(ptr) => {
341341
assert_eq!(target_size, cx.data_layout().pointer_size);
342342
Err(ptr)
@@ -350,7 +350,7 @@ impl<'tcx, Tag> Scalar<Tag> {
350350
fn to_bits(self, target_size: Size) -> InterpResult<'tcx, u128> {
351351
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
352352
match self {
353-
Scalar::Raw(int) => int.to_bits(target_size),
353+
Scalar::Int(int) => int.to_bits(target_size),
354354
Scalar::Ptr(_) => throw_unsup!(ReadPointerAsBytes),
355355
}
356356
}
@@ -364,14 +364,14 @@ impl<'tcx, Tag> Scalar<Tag> {
364364
pub fn assert_ptr(self) -> Pointer<Tag> {
365365
match self {
366366
Scalar::Ptr(p) => p,
367-
Scalar::Raw { .. } => bug!("expected a Pointer but got Raw bits"),
367+
Scalar::Int { .. } => bug!("expected a Pointer but got Raw bits"),
368368
}
369369
}
370370

371371
/// Do not call this method! Dispatch based on the type instead.
372372
#[inline]
373373
pub fn is_bits(self) -> bool {
374-
matches!(self, Scalar::Raw { .. })
374+
matches!(self, Scalar::Int { .. })
375375
}
376376

377377
/// Do not call this method! Dispatch based on the type instead.

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1952,7 +1952,7 @@ impl<'tcx> Operand<'tcx> {
19521952
.unwrap_or_else(|e| panic!("could not compute layout for {:?}: {:?}", ty, e))
19531953
.size;
19541954
let scalar_size = match val {
1955-
Scalar::Raw(int) => int.size(),
1955+
Scalar::Int(int) => int.size(),
19561956
_ => panic!("Invalid scalar type {:?}", val),
19571957
};
19581958
scalar_size == type_size

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -982,27 +982,27 @@ pub trait PrettyPrinter<'tcx>:
982982
None => p!("<dangling pointer>"),
983983
},
984984
// Bool
985-
(Scalar::Raw(int), ty::Bool) if int == ScalarInt::FALSE => p!("false"),
986-
(Scalar::Raw(int), ty::Bool) if int == ScalarInt::TRUE => p!("true"),
985+
(Scalar::Int(int), ty::Bool) if int == ScalarInt::FALSE => p!("false"),
986+
(Scalar::Int(int), ty::Bool) if int == ScalarInt::TRUE => p!("true"),
987987
// Float
988-
(Scalar::Raw(int), ty::Float(ast::FloatTy::F32)) => {
988+
(Scalar::Int(int), ty::Float(ast::FloatTy::F32)) => {
989989
p!(write("{}f32", Single::try_from(int).unwrap()))
990990
}
991-
(Scalar::Raw(int), ty::Float(ast::FloatTy::F64)) => {
991+
(Scalar::Int(int), ty::Float(ast::FloatTy::F64)) => {
992992
p!(write("{}f64", Double::try_from(int).unwrap()))
993993
}
994994
// Int
995-
(Scalar::Raw(int), ty::Uint(_) | ty::Int(_)) => {
995+
(Scalar::Int(int), ty::Uint(_) | ty::Int(_)) => {
996996
let int =
997997
ConstInt::new(int, matches!(ty.kind(), ty::Int(_)), ty.is_ptr_sized_integral());
998998
if print_ty { p!(write("{:#?}", int)) } else { p!(write("{:?}", int)) }
999999
}
10001000
// Char
1001-
(Scalar::Raw(int), ty::Char) if char::try_from(int).is_ok() => {
1001+
(Scalar::Int(int), ty::Char) if char::try_from(int).is_ok() => {
10021002
p!(write("{:?}", char::try_from(int).unwrap()))
10031003
}
10041004
// Raw pointers
1005-
(Scalar::Raw(int), ty::RawPtr(_)) => {
1005+
(Scalar::Int(int), ty::RawPtr(_)) => {
10061006
let data = int.assert_bits(self.tcx().data_layout.pointer_size);
10071007
self = self.typed_value(
10081008
|mut this| {
@@ -1025,11 +1025,11 @@ pub trait PrettyPrinter<'tcx>:
10251025
)?;
10261026
}
10271027
// For function type zsts just printing the path is enough
1028-
(Scalar::Raw(int), ty::FnDef(d, s)) if int == ScalarInt::ZST => {
1028+
(Scalar::Int(int), ty::FnDef(d, s)) if int == ScalarInt::ZST => {
10291029
p!(print_value_path(*d, s))
10301030
}
10311031
// Nontrivial types with scalar bit representation
1032-
(Scalar::Raw(int), _) => {
1032+
(Scalar::Int(int), _) => {
10331033
let print = |mut this: Self| {
10341034
if int.size() == Size::ZERO {
10351035
write!(this, "transmute(())")?;

compiler/rustc_mir/src/const_eval/eval_queries.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub(super) fn op_to_const<'tcx>(
137137
let alloc = ecx.tcx.global_alloc(ptr.alloc_id).unwrap_memory();
138138
ConstValue::ByRef { alloc, offset: ptr.offset }
139139
}
140-
Scalar::Raw(int) => {
140+
Scalar::Int(int) => {
141141
assert!(mplace.layout.is_zst());
142142
assert_eq!(
143143
int.assert_bits(ecx.tcx.data_layout.pointer_size)
@@ -162,7 +162,7 @@ pub(super) fn op_to_const<'tcx>(
162162
Scalar::Ptr(ptr) => {
163163
(ecx.tcx.global_alloc(ptr.alloc_id).unwrap_memory(), ptr.offset.bytes())
164164
}
165-
Scalar::Raw { .. } => (
165+
Scalar::Int { .. } => (
166166
ecx.tcx
167167
.intern_const_alloc(Allocation::from_byte_aligned_bytes(b"" as &[u8])),
168168
0,

compiler/rustc_mir/src/const_eval/machine.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
181181
fn guaranteed_eq(&mut self, a: Scalar, b: Scalar) -> bool {
182182
match (a, b) {
183183
// Comparisons between integers are always known.
184-
(Scalar::Raw { .. }, Scalar::Raw { .. }) => a == b,
184+
(Scalar::Int { .. }, Scalar::Int { .. }) => a == b,
185185
// Equality with integers can never be known for sure.
186-
(Scalar::Raw { .. }, Scalar::Ptr(_)) | (Scalar::Ptr(_), Scalar::Raw { .. }) => false,
186+
(Scalar::Int { .. }, Scalar::Ptr(_)) | (Scalar::Ptr(_), Scalar::Int { .. }) => false,
187187
// FIXME: return `true` for when both sides are the same pointer, *except* that
188188
// some things (like functions and vtables) do not have stable addresses
189189
// so we need to be careful around them (see e.g. #73722).
@@ -194,11 +194,11 @@ impl<'mir, 'tcx: 'mir> CompileTimeEvalContext<'mir, 'tcx> {
194194
fn guaranteed_ne(&mut self, a: Scalar, b: Scalar) -> bool {
195195
match (a, b) {
196196
// Comparisons between integers are always known.
197-
(Scalar::Raw(_), Scalar::Raw(_)) => a != b,
197+
(Scalar::Int(_), Scalar::Int(_)) => a != b,
198198
// Comparisons of abstract pointers with null pointers are known if the pointer
199199
// is in bounds, because if they are in bounds, the pointer can't be null.
200200
// Inequality with integers other than null can never be known for sure.
201-
(Scalar::Raw(int), Scalar::Ptr(ptr)) | (Scalar::Ptr(ptr), Scalar::Raw(int)) => {
201+
(Scalar::Int(int), Scalar::Ptr(ptr)) | (Scalar::Ptr(ptr), Scalar::Int(int)) => {
202202
int == ScalarInt::null(int.size()) && !self.memory.ptr_may_be_null(ptr)
203203
}
204204
// FIXME: return `true` for at least some comparisons where we can reliably

compiler/rustc_mir/src/interpret/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'tcx, Tag: Copy> ImmTy<'tcx, Tag> {
212212
pub fn to_const_int(self) -> ConstInt {
213213
assert!(self.layout.ty.is_integral());
214214
let int = match self.to_scalar().expect("to_const_int doesn't work on scalar pairs") {
215-
Scalar::Raw(int) => int,
215+
Scalar::Int(int) => int,
216216
Scalar::Ptr(_) => bug!("to_const_int doesn't work on pointers"),
217217
};
218218
ConstInt::new(int, self.layout.ty.is_signed(), self.layout.ty.is_ptr_sized_integral())
@@ -541,7 +541,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
541541
let tag_scalar = |scalar| -> InterpResult<'tcx, _> {
542542
Ok(match scalar {
543543
Scalar::Ptr(ptr) => Scalar::Ptr(self.global_base_pointer(ptr)?),
544-
Scalar::Raw(int) => Scalar::Raw(int),
544+
Scalar::Int(int) => Scalar::Int(int),
545545
})
546546
};
547547
// Early-return cases.

compiler/rustc_mir/src/interpret/place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ where
721721
dest.layout.size,
722722
"Size mismatch when writing pointer"
723723
),
724-
Immediate::Scalar(ScalarMaybeUninit::Scalar(Scalar::Raw(int))) => {
724+
Immediate::Scalar(ScalarMaybeUninit::Scalar(Scalar::Int(int))) => {
725725
assert_eq!(int.size(), dest.layout.size, "Size mismatch when writing bits")
726726
}
727727
Immediate::Scalar(ScalarMaybeUninit::Uninit) => {} // uninit can have any size

compiler/rustc_mir/src/transform/simplify_comparison_integral.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<'tcx> MirPass<'tcx> for SimplifyComparisonIntegral {
4040
let bbs = &mut body.basic_blocks_mut();
4141
let bb = &mut bbs[opt.bb_idx];
4242
let new_value = match opt.branch_value_scalar {
43-
Scalar::Raw(int) => {
43+
Scalar::Int(int) => {
4444
let layout = tcx
4545
.layout_of(param_env.and(opt.branch_value_ty))
4646
.expect("if we have an evaluated constant we must know the layout");

0 commit comments

Comments
 (0)