Skip to content

Commit ce822b3

Browse files
committed
rustfmt now supports let else
1 parent f6fbc0d commit ce822b3

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

charon/src/export.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl<FD: Serialize + Clone, GD: Serialize + Clone> GCrateData<FD, GD> {
9191
// Create the file.
9292
let std::io::Result::Ok(outfile) = File::create(target_filename.clone()) else {
9393
error!("Could not open: {:?}", target_filename);
94-
return Err(())
94+
return Err(());
9595
};
9696
// Write to the file.
9797
let std::result::Result::Ok(()) = serde_json::to_writer(&outfile, self) else {

charon/src/transform/remove_dynamic_checks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ fn remove_dynamic_checks(ctx: &mut TransformCtx, block: &mut BlockData) {
1616
cond: Operand::Move(cond),
1717
expected,
1818
target,
19-
} = &block.terminator.content else { return };
19+
} = &block.terminator.content
20+
else {
21+
return;
22+
};
2023

2124
// We return the statements we want to keep, which must be a prefix of `block.statements`.
2225
let statements_to_keep = match block.statements.as_mut_slice() {

charon/src/transform/remove_read_discriminant.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl<'a, 'ctx> Visitor<'a, 'ctx> {
6666
content: RawStatement::Nop,
6767
meta: st.meta,
6868
};
69-
return
69+
return;
7070
};
7171

7272
// We look for a `SwitchInt` just after the discriminant read.
@@ -87,8 +87,11 @@ impl<'a, 'ctx> Visitor<'a, 'ctx> {
8787

8888
match maybe_switch {
8989
Ok((meta2, switch, st3_opt)) => {
90-
let Switch::SwitchInt(Operand::Move(op_p), _int_ty, targets, otherwise) = switch
91-
else { unreachable!() };
90+
let Switch::SwitchInt(Operand::Move(op_p), _int_ty, targets, otherwise) =
91+
switch
92+
else {
93+
unreachable!()
94+
};
9295
assert!(op_p.projection.is_empty() && op_p.var_id == dest.var_id);
9396

9497
// Convert between discriminants and variant indices. Remark: the discriminant can

charon/src/translate/translate_constants.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ impl<'tcx, 'ctx, 'ctx1> BodyTransCtx<'tcx, 'ctx, 'ctx1> {
157157
trait_refs,
158158
trait_info,
159159
)?;
160-
let SubstFunIdOrPanic::Fun(fn_id) = fn_id else { unreachable!() };
160+
let SubstFunIdOrPanic::Fun(fn_id) = fn_id else {
161+
unreachable!()
162+
};
161163
RawConstantExpr::FnPtr(fn_id.func)
162164
}
163165
ConstantExprKind::Todo(msg) => {

charon/tests/ui.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ fn parse_magic_comments(input_path: &std::path::Path) -> anyhow::Result<MagicCom
6868
auxiliary_crates: Vec::new(),
6969
};
7070
for line in read_to_string(input_path)?.lines() {
71-
let Some(line) = line.strip_prefix("//@") else { break };
71+
let Some(line) = line.strip_prefix("//@") else {
72+
break;
73+
};
7274
let line = line.trim();
7375
if line == "known-panic" {
7476
comments.test_kind = TestKind::KnownPanic;

0 commit comments

Comments
 (0)