Skip to content

Commit 018ba05

Browse files
committed
Use wide pointers consistenly across the compiler
1 parent f7c8928 commit 018ba05

File tree

41 files changed

+120
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+120
-120
lines changed

compiler/rustc_codegen_cranelift/example/std_example.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn main() {
168168

169169
foo(I64X2([0, 0]));
170170

171-
transmute_fat_pointer();
171+
transmute_wide_pointer();
172172

173173
rust_call_abi();
174174

@@ -192,7 +192,7 @@ type TwoPtrs = i64;
192192
#[cfg(target_pointer_width = "64")]
193193
type TwoPtrs = i128;
194194

195-
fn transmute_fat_pointer() -> TwoPtrs {
195+
fn transmute_wide_pointer() -> TwoPtrs {
196196
unsafe { transmute::<_, TwoPtrs>("true !") }
197197
}
198198

compiler/rustc_codegen_cranelift/src/base.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -713,17 +713,17 @@ fn codegen_stmt<'tcx>(
713713
let from_ty = operand.layout().ty;
714714
let to_ty = fx.monomorphize(to_ty);
715715

716-
fn is_fat_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
716+
fn is_wide_ptr<'tcx>(fx: &FunctionCx<'_, '_, 'tcx>, ty: Ty<'tcx>) -> bool {
717717
ty.builtin_deref(true)
718718
.is_some_and(|pointee_ty| has_ptr_meta(fx.tcx, pointee_ty))
719719
}
720720

721-
if is_fat_ptr(fx, from_ty) {
722-
if is_fat_ptr(fx, to_ty) {
723-
// fat-ptr -> fat-ptr
721+
if is_wide_ptr(fx, from_ty) {
722+
if is_wide_ptr(fx, to_ty) {
723+
// wide-ptr -> wide-ptr
724724
lval.write_cvalue(fx, operand.cast_pointer_to(dest_layout));
725725
} else {
726-
// fat-ptr -> thin-ptr
726+
// wide-ptr -> thin-ptr
727727
let (ptr, _extra) = operand.load_scalar_pair(fx);
728728
lval.write_cvalue(fx, CValue::by_val(ptr, dest_layout))
729729
}

compiler/rustc_codegen_cranelift/src/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn clif_pair_type_from_ty<'tcx>(
101101
})
102102
}
103103

104-
/// Is a pointer to this type a fat ptr?
104+
/// Is a pointer to this type a wide ptr?
105105
pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
106106
if ty.is_sized(tcx, ParamEnv::reveal_all()) {
107107
return false;

compiler/rustc_codegen_cranelift/src/debuginfo/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ impl DebugContext {
139139

140140
pointer_type_id
141141
} else {
142-
// FIXME implement debuginfo for fat pointers
142+
// FIXME implement debuginfo for wide pointers
143143
self.placeholder_for_type(tcx, type_dbg, ptr_type)
144144
}
145145
}

compiler/rustc_codegen_gcc/src/intrinsic/simd.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
478478
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
479479
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
480480
});
481-
require!(metadata.is_unit(), InvalidMonomorphization::CastFatPointer {
481+
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
482482
span,
483483
name,
484484
ty: in_elem
@@ -493,7 +493,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
493493
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
494494
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
495495
});
496-
require!(metadata.is_unit(), InvalidMonomorphization::CastFatPointer {
496+
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
497497
span,
498498
name,
499499
ty: out_elem

compiler/rustc_codegen_gcc/src/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
207207
// layout.
208208
if let Abi::Scalar(ref scalar) = self.abi {
209209
// Use a different cache for scalars because pointers to DSTs
210-
// can be either fat or thin (data pointers of fat pointers).
210+
// can be either wide or thin (data pointers of wide pointers).
211211
if let Some(&ty) = cx.scalar_types.borrow().get(&self.ty) {
212212
return ty;
213213
}

compiler/rustc_codegen_llvm/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue};
77
use rustc_codegen_ssa::traits::*;
88
use rustc_middle::ty::Ty;
99
use rustc_middle::ty::layout::LayoutOf;
10-
pub(crate) use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
10+
pub(crate) use rustc_middle::ty::layout::{WIDE_PTR_ADDR, WIDE_PTR_EXTRA};
1111
use rustc_middle::{bug, ty};
1212
use rustc_session::config;
1313
pub(crate) use rustc_target::abi::call::*;

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use super::utils::{
3434
};
3535
use crate::common::CodegenCx;
3636
use crate::debuginfo::metadata::type_map::build_type_with_children;
37-
use crate::debuginfo::utils::{FatPtrKind, fat_pointer_kind};
37+
use crate::debuginfo::utils::{WidePtrKind, wide_pointer_kind};
3838
use crate::llvm::debuginfo::{
3939
DIDescriptor, DIFile, DIFlags, DILexicalBlock, DIScope, DIType, DebugEmissionKind,
4040
DebugNameTableKind,
@@ -161,7 +161,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
161161
unique_type_id: UniqueTypeId<'tcx>,
162162
) -> DINodeCreationResult<'ll> {
163163
// The debuginfo generated by this function is only valid if `ptr_type` is really just
164-
// a (fat) pointer. Make sure it is not called for e.g. `Box<T, NonZSTAllocator>`.
164+
// a (wide) pointer. Make sure it is not called for e.g. `Box<T, NonZSTAllocator>`.
165165
assert_eq!(
166166
cx.size_and_align_of(ptr_type),
167167
cx.size_and_align_of(Ty::new_mut_ptr(cx.tcx, pointee_type))
@@ -174,7 +174,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
174174
let data_layout = &cx.tcx.data_layout;
175175
let ptr_type_debuginfo_name = compute_debuginfo_type_name(cx.tcx, ptr_type, true);
176176

177-
match fat_pointer_kind(cx, pointee_type) {
177+
match wide_pointer_kind(cx, pointee_type) {
178178
None => {
179179
// This is a thin pointer. Create a regular pointer type and give it the correct name.
180180
assert_eq!(
@@ -197,7 +197,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
197197

198198
DINodeCreationResult { di_node, already_stored_in_typemap: false }
199199
}
200-
Some(fat_pointer_kind) => {
200+
Some(wide_pointer_kind) => {
201201
type_map::build_type_with_children(
202202
cx,
203203
type_map::stub(
@@ -210,7 +210,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
210210
DIFlags::FlagZero,
211211
),
212212
|cx, owner| {
213-
// FIXME: If this fat pointer is a `Box` then we don't want to use its
213+
// FIXME: If this wide pointer is a `Box` then we don't want to use its
214214
// type layout and instead use the layout of the raw pointer inside
215215
// of it.
216216
// The proper way to handle this is to not treat Box as a pointer
@@ -227,16 +227,16 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
227227
};
228228

229229
let layout = cx.layout_of(layout_type);
230-
let addr_field = layout.field(cx, abi::FAT_PTR_ADDR);
231-
let extra_field = layout.field(cx, abi::FAT_PTR_EXTRA);
230+
let addr_field = layout.field(cx, abi::WIDE_PTR_ADDR);
231+
let extra_field = layout.field(cx, abi::WIDE_PTR_EXTRA);
232232

233-
let (addr_field_name, extra_field_name) = match fat_pointer_kind {
234-
FatPtrKind::Dyn => ("pointer", "vtable"),
235-
FatPtrKind::Slice => ("data_ptr", "length"),
233+
let (addr_field_name, extra_field_name) = match wide_pointer_kind {
234+
WidePtrKind::Dyn => ("pointer", "vtable"),
235+
WidePtrKind::Slice => ("data_ptr", "length"),
236236
};
237237

238-
assert_eq!(abi::FAT_PTR_ADDR, 0);
239-
assert_eq!(abi::FAT_PTR_EXTRA, 1);
238+
assert_eq!(abi::WIDE_PTR_ADDR, 0);
239+
assert_eq!(abi::WIDE_PTR_EXTRA, 1);
240240

241241
// The data pointer type is a regular, thin pointer, regardless of whether this
242242
// is a slice or a trait object.
@@ -258,7 +258,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
258258
owner,
259259
addr_field_name,
260260
(addr_field.size, addr_field.align.abi),
261-
layout.fields.offset(abi::FAT_PTR_ADDR),
261+
layout.fields.offset(abi::WIDE_PTR_ADDR),
262262
DIFlags::FlagZero,
263263
data_ptr_type_di_node,
264264
),
@@ -267,7 +267,7 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
267267
owner,
268268
extra_field_name,
269269
(extra_field.size, extra_field.align.abi),
270-
layout.fields.offset(abi::FAT_PTR_EXTRA),
270+
layout.fields.offset(abi::WIDE_PTR_EXTRA),
271271
DIFlags::FlagZero,
272272
type_di_node(cx, extra_field.ty),
273273
),
@@ -391,7 +391,7 @@ fn build_dyn_type_di_node<'ll, 'tcx>(
391391
///
392392
/// NOTE: We currently emit just emit the debuginfo for the element type here
393393
/// (i.e. `T` for slices and `u8` for `str`), so that we end up with
394-
/// `*const T` for the `data_ptr` field of the corresponding fat-pointer
394+
/// `*const T` for the `data_ptr` field of the corresponding wide-pointer
395395
/// debuginfo of `&[T]`.
396396
///
397397
/// It would be preferable and more accurate if we emitted a DIArray of T

compiler/rustc_codegen_llvm/src/debuginfo/utils.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,23 @@ pub(crate) fn get_namespace_for_item<'ll>(cx: &CodegenCx<'ll, '_>, def_id: DefId
4949
}
5050

5151
#[derive(Debug, PartialEq, Eq)]
52-
pub(crate) enum FatPtrKind {
52+
pub(crate) enum WidePtrKind {
5353
Slice,
5454
Dyn,
5555
}
5656

5757
/// Determines if `pointee_ty` is slice-like or trait-object-like, i.e.
58-
/// if the second field of the fat pointer is a length or a vtable-pointer.
59-
/// If `pointee_ty` does not require a fat pointer (because it is Sized) then
58+
/// if the second field of the wide pointer is a length or a vtable-pointer.
59+
/// If `pointee_ty` does not require a wide pointer (because it is Sized) then
6060
/// the function returns `None`.
61-
pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
61+
pub(crate) fn wide_pointer_kind<'ll, 'tcx>(
6262
cx: &CodegenCx<'ll, 'tcx>,
6363
pointee_ty: Ty<'tcx>,
64-
) -> Option<FatPtrKind> {
64+
) -> Option<WidePtrKind> {
6565
let pointee_tail_ty = cx.tcx.struct_tail_for_codegen(pointee_ty, cx.param_env());
6666
let layout = cx.layout_of(pointee_tail_ty);
6767
trace!(
68-
"fat_pointer_kind: {:?} has layout {:?} (is_unsized? {})",
68+
"wide_pointer_kind: {:?} has layout {:?} (is_unsized? {})",
6969
pointee_tail_ty,
7070
layout,
7171
layout.is_unsized()
@@ -76,8 +76,8 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
7676
}
7777

7878
match *pointee_tail_ty.kind() {
79-
ty::Str | ty::Slice(_) => Some(FatPtrKind::Slice),
80-
ty::Dynamic(..) => Some(FatPtrKind::Dyn),
79+
ty::Str | ty::Slice(_) => Some(WidePtrKind::Slice),
80+
ty::Dynamic(..) => Some(WidePtrKind::Dyn),
8181
ty::Foreign(_) => {
8282
// Assert that pointers to foreign types really are thin:
8383
assert_eq!(
@@ -90,7 +90,7 @@ pub(crate) fn fat_pointer_kind<'ll, 'tcx>(
9090
// For all other pointee types we should already have returned None
9191
// at the beginning of the function.
9292
panic!(
93-
"fat_pointer_kind() - Encountered unexpected `pointee_tail_ty`: {pointee_tail_ty:?}"
93+
"wide_pointer_kind() - Encountered unexpected `pointee_tail_ty`: {pointee_tail_ty:?}"
9494
)
9595
}
9696
}

compiler/rustc_codegen_llvm/src/intrinsic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
21852185
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
21862186
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
21872187
});
2188-
require!(metadata.is_unit(), InvalidMonomorphization::CastFatPointer {
2188+
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
21892189
span,
21902190
name,
21912191
ty: in_elem
@@ -2200,7 +2200,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
22002200
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
22012201
bx.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), ty)
22022202
});
2203-
require!(metadata.is_unit(), InvalidMonomorphization::CastFatPointer {
2203+
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
22042204
span,
22052205
name,
22062206
ty: out_elem

compiler/rustc_codegen_llvm/src/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
199199
// layout.
200200
if let Abi::Scalar(scalar) = self.abi {
201201
// Use a different cache for scalars because pointers to DSTs
202-
// can be either fat or thin (data pointers of fat pointers).
202+
// can be either wide or thin (data pointers of wide pointers).
203203
if let Some(&llty) = cx.scalar_lltypes.borrow().get(&self.ty) {
204204
return llty;
205205
}

compiler/rustc_codegen_ssa/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ codegen_ssa_invalid_monomorphization_basic_integer_type = invalid monomorphizati
8282
8383
codegen_ssa_invalid_monomorphization_cannot_return = invalid monomorphization of `{$name}` intrinsic: cannot return `{$ret_ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
8484
85-
codegen_ssa_invalid_monomorphization_cast_fat_pointer = invalid monomorphization of `{$name}` intrinsic: cannot cast fat pointer `{$ty}`
85+
codegen_ssa_invalid_monomorphization_cast_wide_pointer = invalid monomorphization of `{$name}` intrinsic: cannot cast wide pointer `{$ty}`
8686
8787
codegen_ssa_invalid_monomorphization_expected_element_type = invalid monomorphization of `{$name}` intrinsic: expected element type `{$expected_element}` of second argument `{$second_arg}` to be a pointer to the element type `{$in_elem}` of the first argument `{$in_ty}`, found `{$expected_element}` != `{$mutability} {$in_elem}`
8888

compiler/rustc_codegen_ssa/src/errors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,8 @@ pub enum InvalidMonomorphization<'tcx> {
916916
ret_ty: Ty<'tcx>,
917917
},
918918

919-
#[diag(codegen_ssa_invalid_monomorphization_cast_fat_pointer, code = E0511)]
920-
CastFatPointer {
919+
#[diag(codegen_ssa_invalid_monomorphization_cast_wide_pointer, code = E0511)]
920+
CastWidePointer {
921921
#[primary_span]
922922
span: Span,
923923
name: Symbol,

compiler/rustc_codegen_ssa/src/mir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
133133
enum LocalRef<'tcx, V> {
134134
Place(PlaceRef<'tcx, V>),
135135
/// `UnsizedPlace(p)`: `p` itself is a thin pointer (indirect place).
136-
/// `*p` is the fat pointer that references the actual unsized place.
136+
/// `*p` is the wide pointer that references the actual unsized place.
137137
/// Every time it is initialized, we have to reallocate the place
138-
/// and update the fat pointer. That's the reason why it is indirect.
138+
/// and update the wide pointer. That's the reason why it is indirect.
139139
UnsizedPlace(PlaceRef<'tcx, V>),
140140
/// The backend [`OperandValue`] has already been generated.
141141
Operand(OperandRef<'tcx, V>),
@@ -429,7 +429,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
429429
// Unsized indirect qrguments
430430
PassMode::Indirect { attrs: _, meta_attrs: Some(_), on_stack: _ } => {
431431
// As the storage for the indirect argument lives during
432-
// the whole function call, we just copy the fat pointer.
432+
// the whole function call, we just copy the wide pointer.
433433
let llarg = bx.get_param(llarg_idx);
434434
llarg_idx += 1;
435435
let llextra = bx.get_param(llarg_idx);

compiler/rustc_codegen_ssa/src/mir/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum OperandValue<V> {
4141
/// The backend value in this variant must be the *immediate* backend type,
4242
/// as returned by [`LayoutTypeCodegenMethods::immediate_backend_type`].
4343
Immediate(V),
44-
/// A pair of immediate LLVM values. Used by fat pointers too.
44+
/// A pair of immediate LLVM values. Used by wide pointers too.
4545
///
4646
/// An `OperandValue` *must* be this variant for any type for which
4747
/// [`LayoutTypeCodegenMethods::is_backend_scalar_pair`] returns `true`.

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
3838
ref source,
3939
_,
4040
) => {
41-
// The destination necessarily contains a fat pointer, so if
42-
// it's a scalar pair, it's a fat pointer or newtype thereof.
41+
// The destination necessarily contains a wide pointer, so if
42+
// it's a scalar pair, it's a wide pointer or newtype thereof.
4343
if bx.cx().is_backend_scalar_pair(dest.layout) {
44-
// Into-coerce of a thin pointer to a fat pointer -- just
44+
// Into-coerce of a thin pointer to a wide pointer -- just
4545
// use the operand path.
4646
let temp = self.codegen_rvalue_operand(bx, rvalue);
4747
temp.val.store(bx, dest);
@@ -519,7 +519,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
519519
if bx.cx().is_backend_scalar_pair(cast) {
520520
OperandValue::Pair(data_ptr, meta)
521521
} else {
522-
// Cast of fat-ptr to thin-ptr is an extraction of data-ptr.
522+
// Cast of wide-ptr to thin-ptr is an extraction of data-ptr.
523523
OperandValue::Immediate(data_ptr)
524524
}
525525
} else {
@@ -622,7 +622,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
622622
(
623623
OperandValue::Pair(lhs_addr, lhs_extra),
624624
OperandValue::Pair(rhs_addr, rhs_extra),
625-
) => self.codegen_fat_ptr_binop(
625+
) => self.codegen_wide_ptr_binop(
626626
bx,
627627
op,
628628
lhs_addr,
@@ -984,7 +984,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
984984
}
985985
}
986986

987-
fn codegen_fat_ptr_binop(
987+
fn codegen_wide_ptr_binop(
988988
&mut self,
989989
bx: &mut Bx,
990990
op: mir::BinOp,
@@ -1021,7 +1021,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
10211021
bx.or(lhs, rhs)
10221022
}
10231023
_ => {
1024-
bug!("unexpected fat ptr binop");
1024+
bug!("unexpected wide ptr binop");
10251025
}
10261026
}
10271027
}

compiler/rustc_const_eval/src/interpret/cast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,12 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
204204
) -> InterpResult<'tcx, ImmTy<'tcx, M::Provenance>> {
205205
assert!(src.layout.ty.is_any_ptr());
206206
assert!(cast_to.ty.is_unsafe_ptr());
207-
// Handle casting any ptr to raw ptr (might be a fat ptr).
207+
// Handle casting any ptr to raw ptr (might be a wide ptr).
208208
if cast_to.size == src.layout.size {
209-
// Thin or fat pointer that just has the ptr kind of target type changed.
209+
// Thin or wide pointer that just has the ptr kind of target type changed.
210210
return interp_ok(ImmTy::from_immediate(**src, cast_to));
211211
} else {
212-
// Casting the metadata away from a fat ptr.
212+
// Casting the metadata away from a wide ptr.
213213
assert_eq!(src.layout.size, 2 * self.pointer_size());
214214
assert_eq!(cast_to.size, self.pointer_size());
215215
assert!(src.layout.ty.is_unsafe_ptr());

0 commit comments

Comments
 (0)