Skip to content

Commit 1fa0ff8

Browse files
committed
fix nits
1 parent 9c95522 commit 1fa0ff8

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

src/fn_call.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,14 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx, 'mir> for super::MiriEvalCo
150150
if !align.is_power_of_two() {
151151
return err!(HeapAllocNonPowerOfTwoAlignment(align));
152152
}
153-
let ptr = self.memory_mut().allocate(Size::from_bytes(size),
154-
Align::from_bytes(align, align).unwrap(),
155-
MiriMemoryKind::Rust.into())?;
156-
self.write_scalar(Scalar::Ptr(ptr.with_default_tag()), dest)?;
153+
let ptr = self.memory_mut()
154+
.allocate(
155+
Size::from_bytes(size),
156+
Align::from_bytes(align, align).unwrap(),
157+
MiriMemoryKind::Rust.into()
158+
)?
159+
.with_default_tag();
160+
self.write_scalar(Scalar::Ptr(ptr), dest)?;
157161
}
158162
"__rust_alloc_zeroed" => {
159163
let size = self.read_scalar(args[0])?.to_usize(&self)?;
@@ -164,11 +168,13 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx, 'mir> for super::MiriEvalCo
164168
if !align.is_power_of_two() {
165169
return err!(HeapAllocNonPowerOfTwoAlignment(align));
166170
}
167-
let ptr = self.memory_mut().allocate(
171+
let ptr = self.memory_mut()
172+
.allocate(
168173
Size::from_bytes(size),
169174
Align::from_bytes(align, align).unwrap(),
170175
MiriMemoryKind::Rust.into()
171-
)?.with_default_tag();
176+
)?
177+
.with_default_tag();
172178
self.memory_mut().write_repeat(ptr.into(), 0, Size::from_bytes(size))?;
173179
self.write_scalar(Scalar::Ptr(ptr), dest)?;
174180
}

src/stacked_borrows.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'tcx> Stack {
251251
impl State {
252252
fn increment_clock(&self) -> Timestamp {
253253
let val = self.clock.get();
254-
self.clock.set(val+1);
254+
self.clock.set(val + 1);
255255
val
256256
}
257257
}
@@ -322,13 +322,13 @@ impl<'tcx> Stacks {
322322
/// Pushes the first borrow to the stacks, must be a mutable one.
323323
pub fn first_borrow(
324324
&mut self,
325-
r#mut: Mut,
325+
mut_borrow: Mut,
326326
size: Size
327327
) {
328328
for stack in self.stacks.get_mut().iter_mut(Size::ZERO, size) {
329329
assert!(stack.borrows.len() == 1 && stack.frozen_since.is_none());
330330
assert_eq!(stack.borrows.pop().unwrap(), BorStackItem::Mut(Mut::Raw));
331-
stack.borrows.push(BorStackItem::Mut(r#mut));
331+
stack.borrows.push(BorStackItem::Mut(mut_borrow));
332332
}
333333
}
334334
}
@@ -489,7 +489,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
489489
id: AllocId,
490490
kind: MemoryKind<MiriMemoryKind>,
491491
) -> Borrow {
492-
let r#mut = match kind {
492+
let mut_borrow = match kind {
493493
MemoryKind::Stack => {
494494
// New unique borrow
495495
let time = self.machine.stacked_borrows.increment_clock();
@@ -503,7 +503,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
503503
// Make this the active borrow for this allocation
504504
let alloc = self.memory_mut().get_mut(id).expect("This is a new allocation, it must still exist");
505505
let size = Size::from_bytes(alloc.bytes.len() as u64);
506-
alloc.extra.first_borrow(r#mut, size);
507-
Borrow::Mut(r#mut)
506+
alloc.extra.first_borrow(mut_borrow, size);
507+
Borrow::Mut(mut_borrow)
508508
}
509509
}

tests/compile-fail/stacked_borrows/illegal_write4.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fn main() {
1111
let target = 42;
1212
// Make sure a cannot use a raw-tagged `&mut` pointing to a frozen location, not
1313
// even to create a raw.
14-
let r#ref = &target; // freeze
15-
let ptr = r#ref as *const _ as *mut i32; // raw ptr, with raw tag
14+
let reference = &target; // freeze
15+
let ptr = reference as *const _ as *mut i32; // raw ptr, with raw tag
1616
let mut_ref: &mut i32 = unsafe { mem::transmute(ptr) }; // &mut, with raw tag
1717
// Now we have an &mut to a frozen location, but that is completely normal:
1818
// We'd just unfreeze the location if we used it.
@@ -23,9 +23,9 @@ fn main() {
2323
// turns a raw into a `&mut`. Next, we create a raw ref to a frozen location
2424
// from a `Raw` tag, which can happen legitimately when interior mutability
2525
// is involved.
26-
let _val = *r#ref; // Make sure it is still frozen.
26+
let _val = *reference; // Make sure it is still frozen.
2727

2828
// We only actually unfreeze once we muteate through the bad pointer.
2929
unsafe { *bad_ptr = 42 }; //~ ERROR does not exist on the stack
30-
let _val = *r#ref;
30+
let _val = *reference;
3131
}

0 commit comments

Comments
 (0)