Skip to content

Commit 0341b8a

Browse files
committed
fmt: set force_multiline_blocks=true
1 parent b061307 commit 0341b8a

File tree

11 files changed

+141
-114
lines changed

11 files changed

+141
-114
lines changed

benches/helpers/miri_helper.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ fn find_sysroot() -> String {
4040
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
4141
match (home, toolchain) {
4242
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
43-
_ => option_env!("RUST_SYSROOT")
44-
.expect("need to specify RUST_SYSROOT env var or use rustup or multirust")
45-
.to_owned(),
43+
_ =>
44+
option_env!("RUST_SYSROOT")
45+
.expect("need to specify RUST_SYSROOT env var or use rustup or multirust")
46+
.to_owned(),
4647
}
4748
}
4849

rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ version = "Two"
22
use_small_heuristics = "Max"
33
match_arm_blocks = false
44
match_arm_leading_pipes = "Preserve"
5+
force_multiline_blocks = true

src/bin/miri.rs

+24-17
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,12 @@ fn compile_time_sysroot() -> Option<String> {
203203
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
204204
Some(match (home, toolchain) {
205205
(Some(home), Some(toolchain)) => format!("{}/toolchains/{}", home, toolchain),
206-
_ => option_env!("RUST_SYSROOT")
207-
.expect("To build Miri without rustup, set the `RUST_SYSROOT` env var at build time")
208-
.to_owned(),
206+
_ =>
207+
option_env!("RUST_SYSROOT")
208+
.expect(
209+
"To build Miri without rustup, set the `RUST_SYSROOT` env var at build time",
210+
)
211+
.to_owned(),
209212
})
210213
}
211214

@@ -336,9 +339,10 @@ fn main() {
336339
"warn" => miri::IsolatedOp::Reject(miri::RejectOpWith::Warning),
337340
"warn-nobacktrace" =>
338341
miri::IsolatedOp::Reject(miri::RejectOpWith::WarningWithoutBacktrace),
339-
_ => panic!(
340-
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
341-
),
342+
_ =>
343+
panic!(
344+
"-Zmiri-isolation-error must be `abort`, `hide`, `warn`, or `warn-nobacktrace`"
345+
),
342346
};
343347
}
344348
"-Zmiri-ignore-leaks" => {
@@ -383,10 +387,11 @@ fn main() {
383387
let id: u64 =
384388
match arg.strip_prefix("-Zmiri-track-pointer-tag=").unwrap().parse() {
385389
Ok(id) => id,
386-
Err(err) => panic!(
387-
"-Zmiri-track-pointer-tag requires a valid `u64` argument: {}",
388-
err
389-
),
390+
Err(err) =>
391+
panic!(
392+
"-Zmiri-track-pointer-tag requires a valid `u64` argument: {}",
393+
err
394+
),
390395
};
391396
if let Some(id) = miri::PtrId::new(id) {
392397
miri_config.tracked_pointer_tag = Some(id);
@@ -422,13 +427,15 @@ fn main() {
422427
.parse::<f64>()
423428
{
424429
Ok(rate) if rate >= 0.0 && rate <= 1.0 => rate,
425-
Ok(_) => panic!(
426-
"-Zmiri-compare-exchange-weak-failure-rate must be between `0.0` and `1.0`"
427-
),
428-
Err(err) => panic!(
429-
"-Zmiri-compare-exchange-weak-failure-rate requires a `f64` between `0.0` and `1.0`: {}",
430-
err
431-
),
430+
Ok(_) =>
431+
panic!(
432+
"-Zmiri-compare-exchange-weak-failure-rate must be between `0.0` and `1.0`"
433+
),
434+
Err(err) =>
435+
panic!(
436+
"-Zmiri-compare-exchange-weak-failure-rate requires a `f64` between `0.0` and `1.0`: {}",
437+
err
438+
),
432439
};
433440
miri_config.cmpxchg_weak_failure_rate = rate;
434441
}

src/diagnostics.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ impl fmt::Display for TerminationInfo {
4343
Deadlock => write!(f, "the evaluated program deadlocked"),
4444
MultipleSymbolDefinitions { link_name, .. } =>
4545
write!(f, "multiple definitions of symbol `{}`", link_name),
46-
SymbolShimClashing { link_name, .. } => write!(
47-
f,
48-
"found `{}` symbol definition that clashes with a built-in shim",
49-
link_name
50-
),
46+
SymbolShimClashing { link_name, .. } =>
47+
write!(
48+
f,
49+
"found `{}` symbol definition that clashes with a built-in shim",
50+
link_name
51+
),
5152
}
5253
}
5354
}

src/helpers.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
498498
match err_kind {
499499
NotFound => "ERROR_FILE_NOT_FOUND",
500500
PermissionDenied => "ERROR_ACCESS_DENIED",
501-
_ => throw_unsup_format!(
502-
"io error {:?} cannot be translated into a raw os error",
503-
err_kind
504-
),
501+
_ =>
502+
throw_unsup_format!(
503+
"io error {:?} cannot be translated into a raw os error",
504+
err_kind
505+
),
505506
},
506507
)?
507508
} else {

src/shims/env.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ impl<'tcx> EnvVars<'tcx> {
5353
"linux" | "macos" =>
5454
alloc_env_var_as_c_str(name.as_ref(), value.as_ref(), ecx)?,
5555
"windows" => alloc_env_var_as_wide_str(name.as_ref(), value.as_ref(), ecx)?,
56-
unsupported => throw_unsup_format!(
57-
"environment support for target OS `{}` not yet available",
58-
unsupported
59-
),
56+
unsupported =>
57+
throw_unsup_format!(
58+
"environment support for target OS `{}` not yet available",
59+
unsupported
60+
),
6061
};
6162
ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
6263
}

src/shims/foreign_items.rs

+49-47
Original file line numberDiff line numberDiff line change
@@ -223,54 +223,56 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
223223

224224
// First: functions that diverge.
225225
let (dest, ret) = match ret {
226-
None => match &*link_name.as_str() {
227-
"miri_start_panic" => {
228-
// `check_shim` happens inside `handle_miri_start_panic`.
229-
this.handle_miri_start_panic(abi, link_name, args, unwind)?;
230-
return Ok(None);
231-
}
232-
// This matches calls to the foreign item `panic_impl`.
233-
// The implementation is provided by the function with the `#[panic_handler]` attribute.
234-
"panic_impl" => {
235-
// We don't use `check_shim` here because we are just forwarding to the lang
236-
// item. Argument count checking will be performed when the returned `Body` is
237-
// called.
238-
this.check_abi_and_shim_symbol_clash(abi, Abi::Rust, link_name)?;
239-
let panic_impl_id = tcx.lang_items().panic_impl().unwrap();
240-
let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
241-
return Ok(Some(&*this.load_mir(panic_impl_instance.def, None)?));
242-
}
243-
#[rustfmt::skip]
244-
| "exit"
245-
| "ExitProcess"
246-
=> {
247-
let exp_abi = if link_name.as_str() == "exit" {
248-
Abi::C { unwind: false }
249-
} else {
250-
Abi::System { unwind: false }
251-
};
252-
let &[ref code] = this.check_shim(abi, exp_abi, link_name, args)?;
253-
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
254-
let code = this.read_scalar(code)?.to_i32()?;
255-
throw_machine_stop!(TerminationInfo::Exit(code.into()));
256-
}
257-
"abort" => {
258-
let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
259-
throw_machine_stop!(TerminationInfo::Abort(
260-
"the program aborted execution".to_owned()
261-
))
262-
}
263-
_ => {
264-
if let Some(body) = this.lookup_exported_symbol(link_name)? {
265-
return Ok(Some(body));
226+
None =>
227+
match &*link_name.as_str() {
228+
"miri_start_panic" => {
229+
// `check_shim` happens inside `handle_miri_start_panic`.
230+
this.handle_miri_start_panic(abi, link_name, args, unwind)?;
231+
return Ok(None);
266232
}
267-
this.handle_unsupported(format!(
268-
"can't call (diverging) foreign function: {}",
269-
link_name
270-
))?;
271-
return Ok(None);
272-
}
273-
},
233+
// This matches calls to the foreign item `panic_impl`.
234+
// The implementation is provided by the function with the `#[panic_handler]` attribute.
235+
"panic_impl" => {
236+
// We don't use `check_shim` here because we are just forwarding to the lang
237+
// item. Argument count checking will be performed when the returned `Body` is
238+
// called.
239+
this.check_abi_and_shim_symbol_clash(abi, Abi::Rust, link_name)?;
240+
let panic_impl_id = tcx.lang_items().panic_impl().unwrap();
241+
let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
242+
return Ok(Some(&*this.load_mir(panic_impl_instance.def, None)?));
243+
}
244+
#[rustfmt::skip]
245+
| "exit"
246+
| "ExitProcess"
247+
=> {
248+
let exp_abi = if link_name.as_str() == "exit" {
249+
Abi::C { unwind: false }
250+
} else {
251+
Abi::System { unwind: false }
252+
};
253+
let &[ref code] = this.check_shim(abi, exp_abi, link_name, args)?;
254+
// it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
255+
let code = this.read_scalar(code)?.to_i32()?;
256+
throw_machine_stop!(TerminationInfo::Exit(code.into()));
257+
}
258+
"abort" => {
259+
let &[] =
260+
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
261+
throw_machine_stop!(TerminationInfo::Abort(
262+
"the program aborted execution".to_owned()
263+
))
264+
}
265+
_ => {
266+
if let Some(body) = this.lookup_exported_symbol(link_name)? {
267+
return Ok(Some(body));
268+
}
269+
this.handle_unsupported(format!(
270+
"can't call (diverging) foreign function: {}",
271+
link_name
272+
))?;
273+
return Ok(None);
274+
}
275+
},
274276
Some(p) => p,
275277
};
276278

src/shims/intrinsics.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
295295
this.float_to_int_unchecked(val.to_scalar()?.to_f32()?, dest.layout.ty)?,
296296
ty::Float(FloatTy::F64) =>
297297
this.float_to_int_unchecked(val.to_scalar()?.to_f64()?, dest.layout.ty)?,
298-
_ => bug!(
299-
"`float_to_int_unchecked` called with non-float input type {:?}",
300-
val.layout.ty
301-
),
298+
_ =>
299+
bug!(
300+
"`float_to_int_unchecked` called with non-float input type {:?}",
301+
val.layout.ty
302+
),
302303
};
303304

304305
this.write_scalar(res, dest)?;

src/shims/posix/fs.rs

+27-18
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,11 @@ trait EvalContextExtPrivate<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, '
434434
Err(e) =>
435435
return match e.raw_os_error() {
436436
Some(error) => Ok(error),
437-
None => throw_unsup_format!(
438-
"the error {} couldn't be converted to a return value",
439-
e
440-
),
437+
None =>
438+
throw_unsup_format!(
439+
"the error {} couldn't be converted to a return value",
440+
e
441+
),
441442
},
442443
}
443444
}
@@ -1203,13 +1204,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
12031204
this.write_null(&this.deref_operand(result_op)?.into())?;
12041205
Ok(0)
12051206
}
1206-
Some(Err(e)) => match e.raw_os_error() {
1207-
// return positive error number on error
1208-
Some(error) => Ok(error),
1209-
None => {
1210-
throw_unsup_format!("the error {} couldn't be converted to a return value", e)
1211-
}
1212-
},
1207+
Some(Err(e)) =>
1208+
match e.raw_os_error() {
1209+
// return positive error number on error
1210+
Some(error) => Ok(error),
1211+
None => {
1212+
throw_unsup_format!(
1213+
"the error {} couldn't be converted to a return value",
1214+
e
1215+
)
1216+
}
1217+
},
12131218
}
12141219
}
12151220

@@ -1294,13 +1299,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
12941299
this.write_null(&this.deref_operand(result_op)?.into())?;
12951300
Ok(0)
12961301
}
1297-
Some(Err(e)) => match e.raw_os_error() {
1298-
// return positive error number on error
1299-
Some(error) => Ok(error),
1300-
None => {
1301-
throw_unsup_format!("the error {} couldn't be converted to a return value", e)
1302-
}
1303-
},
1302+
Some(Err(e)) =>
1303+
match e.raw_os_error() {
1304+
// return positive error number on error
1305+
Some(error) => Ok(error),
1306+
None => {
1307+
throw_unsup_format!(
1308+
"the error {} couldn't be converted to a return value",
1309+
e
1310+
)
1311+
}
1312+
},
13041313
}
13051314
}
13061315

src/stacked_borrows.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
699699
fn qualify(ty: ty::Ty<'_>, kind: RetagKind) -> Option<(RefKind, bool)> {
700700
match ty.kind() {
701701
// References are simple.
702-
ty::Ref(_, _, Mutability::Mut) => Some((
703-
RefKind::Unique { two_phase: kind == RetagKind::TwoPhase },
704-
kind == RetagKind::FnEntry,
705-
)),
702+
ty::Ref(_, _, Mutability::Mut) =>
703+
Some((
704+
RefKind::Unique { two_phase: kind == RetagKind::TwoPhase },
705+
kind == RetagKind::FnEntry,
706+
)),
706707
ty::Ref(_, _, Mutability::Not) =>
707708
Some((RefKind::Shared, kind == RetagKind::FnEntry)),
708709
// Raw pointers need to be enabled.

src/vector_clock.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,18 @@ impl PartialOrd for VClock {
186186
Ordering::Equal => Some(order),
187187
// Right has at least 1 element > than the implicit 0,
188188
// so the only valid values are Ordering::Less or None.
189-
Ordering::Less => match order {
190-
Ordering::Less | Ordering::Equal => Some(Ordering::Less),
191-
Ordering::Greater => None,
192-
},
189+
Ordering::Less =>
190+
match order {
191+
Ordering::Less | Ordering::Equal => Some(Ordering::Less),
192+
Ordering::Greater => None,
193+
},
193194
// Left has at least 1 element > than the implicit 0,
194195
// so the only valid values are Ordering::Greater or None.
195-
Ordering::Greater => match order {
196-
Ordering::Greater | Ordering::Equal => Some(Ordering::Greater),
197-
Ordering::Less => None,
198-
},
196+
Ordering::Greater =>
197+
match order {
198+
Ordering::Greater | Ordering::Equal => Some(Ordering::Greater),
199+
Ordering::Less => None,
200+
},
199201
}
200202
}
201203

0 commit comments

Comments
 (0)