Skip to content

Commit 536c910

Browse files
author
The Miri Conjob Bot
committed
fmt
1 parent b13a9fa commit 536c910

File tree

7 files changed

+26
-19
lines changed

7 files changed

+26
-19
lines changed

src/tools/miri/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(Ty::new_mut_ptr(this.tcx.tcx,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/tools/miri/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(Ty::new_mut_ptr(this.tcx.tcx,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/tools/miri/src/eval.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,19 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
305305
for arg in config.args.iter() {
306306
// Make space for `0` terminator.
307307
let size = u64::try_from(arg.len()).unwrap().checked_add(1).unwrap();
308-
let arg_type = Ty::new_array(tcx,tcx.types.u8, size);
308+
let arg_type = Ty::new_array(tcx, tcx.types.u8, size);
309309
let arg_place =
310310
ecx.allocate(ecx.layout_of(arg_type)?, MiriMemoryKind::Machine.into())?;
311311
ecx.write_os_str_to_c_str(OsStr::new(arg), arg_place.ptr, size)?;
312312
ecx.mark_immutable(&arg_place);
313313
argvs.push(arg_place.to_ref(&ecx));
314314
}
315315
// Make an array with all these pointers, in the Miri memory.
316-
let argvs_layout = ecx.layout_of(
317-
Ty::new_array(tcx,Ty::new_imm_ptr(tcx,tcx.types.u8), u64::try_from(argvs.len()).unwrap()),
318-
)?;
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+
))?;
319321
let argvs_place = ecx.allocate(argvs_layout, MiriMemoryKind::Machine.into())?;
320322
for (idx, arg) in argvs.into_iter().enumerate() {
321323
let place = ecx.mplace_field(&argvs_place, idx)?;
@@ -333,7 +335,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
333335
ecx.machine.argc = Some(*argc_place);
334336

335337
let argv_place = ecx.allocate(
336-
ecx.layout_of(Ty::new_imm_ptr(tcx,tcx.types.unit))?,
338+
ecx.layout_of(Ty::new_imm_ptr(tcx, tcx.types.unit))?,
337339
MiriMemoryKind::Machine.into(),
338340
)?;
339341
ecx.write_immediate(argv, &argv_place.into())?;
@@ -345,7 +347,8 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
345347
// Construct a command string with all the arguments.
346348
let cmd_utf16: Vec<u16> = args_to_utf16_command_string(config.args.iter());
347349

348-
let cmd_type = Ty::new_array(tcx,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());
349352
let cmd_place =
350353
ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Machine.into())?;
351354
ecx.machine.cmd_line = Some(*cmd_place);

src/tools/miri/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 = Ty::new_ptr(tcx,TypeAndMut { ty: tcx.types.unit, mutbl: Mutability::Mut });
317-
let const_raw_ptr = Ty::new_ptr(tcx,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(Ty::new_unit(tcx,))?,
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/tools/miri/src/shims/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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(Ty::new_array(tcx.tcx,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/tools/miri/src/shims/env.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::mem;
55

66
use rustc_const_eval::interpret::Pointer;
77
use rustc_data_structures::fx::FxHashMap;
8-
use rustc_middle::ty::Ty;
98
use rustc_middle::ty::layout::LayoutOf;
9+
use rustc_middle::ty::Ty;
1010
use rustc_target::abi::Size;
1111

1212
use crate::helpers::target_os_is_unix;
@@ -449,9 +449,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
449449
vars.push(Pointer::null());
450450
// Make an array with all these pointers inside Miri.
451451
let tcx = this.tcx;
452-
let vars_layout = this.layout_of(
453-
Ty::new_array(tcx.tcx,this.machine.layouts.mut_raw_ptr.ty, u64::try_from(vars.len()).unwrap()),
454-
)?;
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+
))?;
455457
let vars_place = this.allocate(vars_layout, MiriMemoryKind::Runtime.into())?;
456458
for (idx, var) in vars.into_iter().enumerate() {
457459
let place = this.mplace_field(&vars_place, idx)?;

src/tools/miri/src/shims/os_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use std::os::unix::ffi::{OsStrExt, OsStringExt};
77
#[cfg(windows)]
88
use std::os::windows::ffi::{OsStrExt, OsStringExt};
99

10-
use rustc_middle::ty::Ty;
1110
use rustc_middle::ty::layout::LayoutOf;
11+
use rustc_middle::ty::Ty;
1212

1313
use crate::*;
1414

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

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

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

0 commit comments

Comments
 (0)