Skip to content

Commit 734fa6c

Browse files
committed
Prefer no blocks around trivial match arms
1 parent c229719 commit 734fa6c

File tree

8 files changed

+23
-33
lines changed

8 files changed

+23
-33
lines changed

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
use_small_heuristics = "Max"
22
version = "Two"
3+
match_arm_blocks = false

src/bin/cargo-miri.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,10 @@ fn inside_cargo_rustc() {
551551
}
552552

553553
match command.status() {
554-
Ok(exit) => {
554+
Ok(exit) =>
555555
if !exit.success() {
556556
std::process::exit(exit.code().unwrap_or(42));
557-
}
558-
}
557+
},
559558
Err(ref e) if needs_miri => panic!("error during miri run: {:?}", e),
560559
Err(ref e) => panic!("error during rustc call: {:?}", e),
561560
}

src/bin/miri.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ fn main() {
167167
FromHexError::InvalidHexCharacter { .. } => panic!(
168168
"-Zmiri-seed should only contain valid hex digits [0-9a-fA-F]"
169169
),
170-
FromHexError::OddLength => {
171-
panic!("-Zmiri-seed should have an even number of digits")
172-
}
170+
FromHexError::OddLength =>
171+
panic!("-Zmiri-seed should have an even number of digits"),
173172
err => panic!("Unknown error decoding -Zmiri-seed as hex: {:?}", err),
174173
});
175174
if seed_raw.len() > 8 {

src/eval.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,21 +215,18 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
215215
.expect("invalid MachineStop payload");
216216
match info {
217217
TerminationInfo::Exit(code) => return Some(*code),
218-
TerminationInfo::PoppedTrackedPointerTag(item) => {
219-
format!("popped tracked tag for item {:?}", item)
220-
}
221-
TerminationInfo::Abort => {
222-
format!("the evaluated program aborted execution")
223-
}
218+
TerminationInfo::PoppedTrackedPointerTag(item) =>
219+
format!("popped tracked tag for item {:?}", item),
220+
TerminationInfo::Abort =>
221+
format!("the evaluated program aborted execution"),
224222
}
225223
}
226224
err_unsup!(NoMirFor(..)) => format!(
227225
"{}. Did you set `MIRI_SYSROOT` to a Miri-enabled sysroot? You can prepare one with `cargo miri setup`.",
228226
e
229227
),
230-
InterpError::InvalidProgram(_) => {
231-
bug!("This error should be impossible in Miri: {}", e)
232-
}
228+
InterpError::InvalidProgram(_) =>
229+
bug!("This error should be impossible in Miri: {}", e),
233230
_ => e.to_string(),
234231
};
235232
e.print_backtrace();

src/helpers.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
239239
fn visit_value(&mut self, v: MPlaceTy<'tcx, Tag>) -> InterpResult<'tcx> {
240240
trace!("UnsafeCellVisitor: {:?} {:?}", *v, v.layout.ty);
241241
let is_unsafe_cell = match v.layout.ty.kind {
242-
ty::Adt(adt, _) => {
243-
Some(adt.did) == self.ecx.tcx.lang_items().unsafe_cell_type()
244-
}
242+
ty::Adt(adt, _) =>
243+
Some(adt.did) == self.ecx.tcx.lang_items().unsafe_cell_type(),
245244
_ => false,
246245
};
247246
if is_unsafe_cell {

src/shims/env.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
5858
let name = this.memory.read_c_str(name_ptr)?;
5959
Ok(match this.machine.env_vars.map.get(name) {
6060
// The offset is used to strip the "{name}=" part of the string.
61-
Some(var_ptr) => {
62-
Scalar::from(var_ptr.offset(Size::from_bytes(name.len() as u64 + 1), this)?)
63-
}
61+
Some(var_ptr) =>
62+
Scalar::from(var_ptr.offset(Size::from_bytes(name.len() as u64 + 1), this)?),
6463
None => Scalar::ptr_null(&*this.tcx),
6564
})
6665
}

src/shims/intrinsics.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
3737
throw_machine_stop!(TerminationInfo::Abort);
3838
}
3939
"miri_start_panic" => return this.handle_miri_start_panic(args, unwind),
40-
_ => {
40+
_ =>
4141
if let Some(p) = ret {
4242
p
4343
} else {
4444
throw_unsup_format!("unimplemented (diverging) intrinsic: {}", intrinsic_name);
45-
}
46-
}
45+
},
4746
};
4847

4948
match intrinsic_name {
@@ -375,9 +374,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
375374
this.write_scalar(Scalar::from_f64(res), dest)?;
376375
}
377376

378-
"exact_div" => {
379-
this.exact_div(this.read_immediate(args[0])?, this.read_immediate(args[1])?, dest)?
380-
}
377+
"exact_div" =>
378+
this.exact_div(this.read_immediate(args[0])?, this.read_immediate(args[1])?, dest)?,
381379

382380
"forget" => {}
383381

src/stacked_borrows.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,8 @@ impl Stacks {
455455
// Thus we call `static_base_ptr` such that the global pointers get the same tag
456456
// as what we use here.
457457
// The base pointer is not unique, so the base permission is `SharedReadWrite`.
458-
MemoryKind::Machine(MiriMemoryKind::Static) => {
459-
(extra.borrow_mut().static_base_ptr(id), Permission::SharedReadWrite)
460-
}
458+
MemoryKind::Machine(MiriMemoryKind::Static) =>
459+
(extra.borrow_mut().static_base_ptr(id), Permission::SharedReadWrite),
461460
// Everything else we handle entirely untagged for now.
462461
// FIXME: experiment with more precise tracking.
463462
_ => (Tag::Untagged, Permission::SharedReadWrite),
@@ -611,9 +610,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
611610
)),
612611
ty::Ref(_, _, Immutable) => Some((RefKind::Shared, kind == RetagKind::FnEntry)),
613612
// Raw pointers need to be enabled.
614-
ty::RawPtr(tym) if kind == RetagKind::Raw => {
615-
Some((RefKind::Raw { mutable: tym.mutbl == Mutable }, false))
616-
}
613+
ty::RawPtr(tym) if kind == RetagKind::Raw =>
614+
Some((RefKind::Raw { mutable: tym.mutbl == Mutable }, false)),
617615
// Boxes do not get a protector: protectors reflect that references outlive the call
618616
// they were passed in to; that's just not the case for boxes.
619617
ty::Adt(..) if ty.is_box() => Some((RefKind::Unique { two_phase: false }, false)),

0 commit comments

Comments
 (0)