Skip to content

Commit c3497e8

Browse files
authored
Rollup merge of #124957 - compiler-errors:builtin-deref, r=michaelwoerister
Make `Ty::builtin_deref` just return a `Ty` Nowhere in the compiler are we using the mutability part of the `TyAndMut` that we used to return.
2 parents 2ccdae1 + fb34667 commit c3497e8

File tree

5 files changed

+5
-6
lines changed

5 files changed

+5
-6
lines changed

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl NewPermission {
136136
cx: &crate::MiriInterpCx<'_, 'tcx>,
137137
) -> Self {
138138
// `ty` is not the `Box` but the field of the Box with this pointer (due to allocator handling).
139-
let pointee = ty.builtin_deref(true).unwrap().ty;
139+
let pointee = ty.builtin_deref(true).unwrap();
140140
if pointee.is_unpin(*cx.tcx, cx.param_env()) {
141141
// A regular box. On `FnEntry` this is `noalias`, but not `dereferenceable` (hence only
142142
// a weak protector).

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'tcx> NewPermission {
173173
cx: &crate::MiriInterpCx<'_, 'tcx>,
174174
zero_size: bool,
175175
) -> Option<Self> {
176-
let pointee = ty.builtin_deref(true).unwrap().ty;
176+
let pointee = ty.builtin_deref(true).unwrap();
177177
pointee.is_unpin(*cx.tcx, cx.param_env()).then_some(()).map(|()| {
178178
// Regular `Unpin` box, give it `noalias` but only a weak protector
179179
// because it is valid to deallocate it within the function.

src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
117117

118118
"write_bytes" | "volatile_set_memory" => {
119119
let [ptr, val_byte, count] = check_arg_count(args)?;
120-
let ty = ptr.layout.ty.builtin_deref(true).unwrap().ty;
120+
let ty = ptr.layout.ty.builtin_deref(true).unwrap();
121121
let ty_layout = this.layout_of(ty)?;
122122
let val_byte = this.read_scalar(val_byte)?.to_u8()?;
123123
let ptr = this.read_pointer(ptr)?;

src/intrinsics/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
267267
Op::WrappingOffset => {
268268
let ptr = left.to_scalar().to_pointer(this)?;
269269
let offset_count = right.to_scalar().to_target_isize(this)?;
270-
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap().ty;
270+
let pointee_ty = left.layout.ty.builtin_deref(true).unwrap();
271271

272272
let pointee_size = i64::try_from(this.layout_of(pointee_ty)?.size.bytes()).unwrap();
273273
let offset_bytes = offset_count.wrapping_mul(pointee_size);

src/shims/unix/foreign_items.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
378378
.builtin_deref(true)
379379
.ok_or_else(|| err_ub_format!(
380380
"wrong signature used for `pthread_key_create`: first argument must be a raw pointer."
381-
))?
382-
.ty;
381+
))?;
383382
let key_layout = this.layout_of(key_type)?;
384383

385384
// Create key and write it into the memory where `key_ptr` wants it.

0 commit comments

Comments
 (0)