Skip to content

Commit

Permalink
Auto merge of #122852 - compiler-errors:raw-ptr, r=lcnr
Browse files Browse the repository at this point in the history
Remove `TypeAndMut` from `ty::RawPtr` variant, make it take `Ty` and `Mutability`

Pretty much mechanically converting `ty::RawPtr(ty::TypeAndMut { ty, mutbl })` to `ty::RawPtr(ty, mutbl)` and its fallout.

r? lcnr

cc rust-lang/types-team#124
  • Loading branch information
bors committed Mar 22, 2024
2 parents 920b37f + a048b16 commit 460b7d7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl NewPermission {
}
}
}
ty::RawPtr(ty::TypeAndMut { mutbl: Mutability::Mut, .. }) => {
ty::RawPtr(_, Mutability::Mut) => {
assert!(protector.is_none()); // RetagKind can't be both FnEntry and Raw.
// Mutable raw pointer. No access, not protected.
NewPermission::Uniform {
Expand All @@ -114,7 +114,7 @@ impl NewPermission {
// This fixes https://github.com/rust-lang/rust/issues/55005.
}
}
ty::RawPtr(ty::TypeAndMut { mutbl: Mutability::Not, .. }) => {
ty::RawPtr(_, Mutability::Not) => {
assert!(protector.is_none()); // RetagKind can't be both FnEntry and Raw.
// `*const T`, when freshly created, are read-only in the frozen part.
NewPermission::FreezeSensitive {
Expand Down
2 changes: 1 addition & 1 deletion src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
NewPermission::from_ref_ty(pointee, mutability, self.kind, self.ecx);
self.retag_ptr_inplace(place, new_perm)?;
}
ty::RawPtr(_) => {
ty::RawPtr(_, _) => {
// We definitely do *not* want to recurse into raw pointers -- wide raw
// pointers have fields, and for dyn Trait pointees those can have reference
// type!
Expand Down
7 changes: 3 additions & 4 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use rand::rngs::StdRng;
use rand::Rng;
use rand::SeedableRng;

use rustc_ast::ast::Mutability;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
#[allow(unused)]
use rustc_data_structures::static_assert_size;
Expand All @@ -22,7 +21,7 @@ use rustc_middle::{
ty::{
self,
layout::{LayoutCx, LayoutError, LayoutOf, TyAndLayout},
Instance, Ty, TyCtxt, TypeAndMut,
Instance, Ty, TyCtxt,
},
};
use rustc_span::def_id::{CrateNum, DefId};
Expand Down Expand Up @@ -374,9 +373,9 @@ impl<'mir, 'tcx: 'mir> PrimitiveLayouts<'tcx> {
fn new(layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Result<Self, &'tcx LayoutError<'tcx>> {
let tcx = layout_cx.tcx;
let mut_raw_ptr =
Ty::new_ptr(tcx, TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Mut });
Ty::new_mut_ptr(tcx, tcx.types.unit);
let const_raw_ptr =
Ty::new_ptr(tcx, TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Not });
Ty::new_imm_ptr(tcx, tcx.types.unit);
Ok(Self {
unit: layout_cx.layout_of(Ty::new_unit(tcx))?,
i8: layout_cx.layout_of(tcx.types.i8)?,
Expand Down

0 comments on commit 460b7d7

Please sign in to comment.