Skip to content

Commit 17e55fc

Browse files
committed
Auto merge of #2970 - rust-lang:rustup2023-07-07, r=oli-obk
Automatic sync from rustc
2 parents 8b9be80 + 61436f8 commit 17e55fc

File tree

8 files changed

+29
-19
lines changed

8 files changed

+29
-19
lines changed

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d5a74249c843e06b502fb097ebea2383b9a5d9b8
1+
bb548f964572f7fe652716f5897d9050a31c936e

src/borrow_tracker/stacked_borrows/mod.rs

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

10121012
// We have to turn the place into a pointer to use the existing code.
10131013
// (The pointer type does not matter, so we use a raw pointer.)
1014-
let ptr_layout = this.layout_of(this.tcx.mk_mut_ptr(return_place.layout.ty))?;
1014+
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, return_place.layout.ty))?;
10151015
let val = ImmTy::from_immediate(return_place.to_ref(this), ptr_layout);
10161016
// Reborrow it. With protection! That is part of the point.
10171017
let new_perm = NewPermission::Uniform {

src/borrow_tracker/tree_borrows/mod.rs

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

512512
// We have to turn the place into a pointer to use the existing code.
513513
// (The pointer type does not matter, so we use a raw pointer.)
514-
let ptr_layout = this.layout_of(this.tcx.mk_mut_ptr(return_place.layout.ty))?;
514+
let ptr_layout = this.layout_of(Ty::new_mut_ptr(this.tcx.tcx, return_place.layout.ty))?;
515515
let val = ImmTy::from_immediate(return_place.to_ref(this), ptr_layout);
516516
// Reborrow it. With protection! That is part of the point.
517517
// FIXME: do we truly want a 2phase borrow here?

src/eval.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::task::Poll;
88
use std::thread;
99

1010
use log::info;
11+
use rustc_middle::ty::Ty;
1112

1213
use crate::borrow_tracker::RetagFields;
1314
use crate::diagnostics::report_leaks;
@@ -304,17 +305,19 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
304305
for arg in config.args.iter() {
305306
// Make space for `0` terminator.
306307
let size = u64::try_from(arg.len()).unwrap().checked_add(1).unwrap();
307-
let arg_type = tcx.mk_array(tcx.types.u8, size);
308+
let arg_type = Ty::new_array(tcx, tcx.types.u8, size);
308309
let arg_place =
309310
ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Machine.into())?;
310311
ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
311312
ecx.mark_immutable(&arg_place);
312313
argvs.push(arg_place.to_ref(&ecx));
313314
}
314315
// Make an array with all these pointers, in the Miri memory.
315-
let argvs_layout = ecx.layout_of(
316-
tcx.mk_array(tcx.mk_imm_ptr(tcx.types.u8), u64::try_from(argvs.len()).unwrap()),
317-
)?;
316+
let argvs_layout = ecx.layout_of(Ty::new_array(
317+
tcx,
318+
Ty::new_imm_ptr(tcx, tcx.types.u8),
319+
u64::try_from(argvs.len()).unwrap(),
320+
))?;
318321
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into())?;
319322
for (idx, arg) in argvs.into_iter().enumerate() {
320323
let place = ecx.mplace_field(&argvs_place, idx)?;
@@ -332,7 +335,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
332335
ecx.machine.argc = Some(*argc_place);
333336

334337
let argv_place = ecx.allocate(
335-
ecx.layout_of(tcx.mk_imm_ptr(tcx.types.unit))?,
338+
ecx.layout_of(Ty::new_imm_ptr(tcx, tcx.types.unit))?,
336339
MiriMemoryKind::Machine.into(),
337340
)?;
338341
ecx.write_immediate(argv, &argv_place.into())?;
@@ -344,7 +347,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
344347
// Construct a command string with all the arguments.
345348
let cmd_utf16: Vec<u16> = args_to_utf16_command_string(config.args.iter());
346349

347-
let cmd_type = tcx.mk_array(tcx.types.u16, u64::try_from(cmd_utf16.len()).unwrap());
350+
let cmd_type =
351+
Ty::new_array(tcx, tcx.types.u16, u64::try_from(cmd_utf16.len()).unwrap());
348352
let cmd_place =
349353
ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Machine.into())?;
350354
ecx.machine.cmd_line = Some(*cmd_place);

src/machine.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,12 @@ pub struct PrimitiveLayouts<'tcx> {
313313
impl<'mir, 'tcx: 'mir> PrimitiveLayouts<'tcx> {
314314
fn new(layout_cx: LayoutCx<'tcx, TyCtxt<'tcx>>) -> Result<Self, &'tcx LayoutError<'tcx>> {
315315
let tcx = layout_cx.tcx;
316-
let mut_raw_ptr = tcx.mk_ptr(TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Mut });
317-
let const_raw_ptr = tcx.mk_ptr(TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Not });
316+
let mut_raw_ptr =
317+
Ty::new_ptr(tcx, TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Mut });
318+
let const_raw_ptr =
319+
Ty::new_ptr(tcx, TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Not });
318320
Ok(Self {
319-
unit: layout_cx.layout_of(tcx.mk_unit())?,
321+
unit: layout_cx.layout_of(Ty::new_unit(tcx))?,
320322
i8: layout_cx.layout_of(tcx.types.i8)?,
321323
i16: layout_cx.layout_of(tcx.types.i16)?,
322324
i32: layout_cx.layout_of(tcx.types.i32)?,

src/shims/backtrace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::*;
22
use rustc_ast::ast::Mutability;
33
use rustc_middle::ty::layout::LayoutOf as _;
4-
use rustc_middle::ty::{self, Instance};
4+
use rustc_middle::ty::{self, Instance, Ty};
55
use rustc_span::{BytePos, Loc, Symbol};
66
use rustc_target::{abi::Size, spec::abi::Abi};
77

@@ -71,7 +71,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7171
let len: u64 = ptrs.len().try_into().unwrap();
7272

7373
let ptr_ty = this.machine.layouts.mut_raw_ptr.ty;
74-
let array_layout = this.layout_of(tcx.mk_array(ptr_ty, len)).unwrap();
74+
let array_layout = this.layout_of(Ty::new_array(tcx.tcx, ptr_ty, len)).unwrap();
7575

7676
match flags {
7777
// storage for pointers is allocated by miri

src/shims/env.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::mem;
66
use rustc_const_eval::interpret::Pointer;
77
use rustc_data_structures::fx::FxHashMap;
88
use rustc_middle::ty::layout::LayoutOf;
9+
use rustc_middle::ty::Ty;
910
use rustc_target::abi::Size;
1011

1112
use crate::helpers::target_os_is_unix;
@@ -448,9 +449,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
448449
vars.push(Pointer::null());
449450
// Make an array with all these pointers inside Miri.
450451
let tcx = this.tcx;
451-
let vars_layout = this.layout_of(
452-
tcx.mk_array(this.machine.layouts.mut_raw_ptr.ty, u64::try_from(vars.len()).unwrap()),
453-
)?;
452+
let vars_layout = this.layout_of(Ty::new_array(
453+
tcx.tcx,
454+
this.machine.layouts.mut_raw_ptr.ty,
455+
u64::try_from(vars.len()).unwrap(),
456+
))?;
454457
let vars_place = this.allocate(vars_layout, MiriMemoryKind::Runtime.into())?;
455458
for (idx, var) in vars.into_iter().enumerate() {
456459
let place = this.mplace_field(&vars_place, idx)?;

src/shims/os_str.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::os::unix::ffi::{OsStrExt, OsStringExt};
88
use std::os::windows::ffi::{OsStrExt, OsStringExt};
99

1010
use rustc_middle::ty::layout::LayoutOf;
11+
use rustc_middle::ty::Ty;
1112

1213
use crate::*;
1314

@@ -140,7 +141,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
140141
let size = u64::try_from(os_str.len()).unwrap().checked_add(1).unwrap(); // Make space for `0` terminator.
141142
let this = self.eval_context_mut();
142143

143-
let arg_type = this.tcx.mk_array(this.tcx.types.u8, size);
144+
let arg_type = Ty::new_array(this.tcx.tcx, this.tcx.types.u8, size);
144145
let arg_place = this.allocate(this.layout_of(arg_type).unwrap(), memkind)?;
145146
let (written, _) = self.write_os_str_to_c_str(os_str, arg_place.ptr, size).unwrap();
146147
assert!(written);
@@ -156,7 +157,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
156157
let size = u64::try_from(os_str.len()).unwrap().checked_add(1).unwrap(); // Make space for `0x0000` terminator.
157158
let this = self.eval_context_mut();
158159

159-
let arg_type = this.tcx.mk_array(this.tcx.types.u16, size);
160+
let arg_type = Ty::new_array(this.tcx.tcx, this.tcx.types.u16, size);
160161
let arg_place = this.allocate(this.layout_of(arg_type).unwrap(), memkind)?;
161162
let (written, _) =
162163
self.write_os_str_to_wide_str(os_str, arg_place.ptr, size, /*truncate*/ false).unwrap();

0 commit comments

Comments
 (0)