Skip to content

Commit 4995e0b

Browse files
committed
Use match instead of if let chain
1 parent 466079c commit 4995e0b

File tree

1 file changed

+23
-17
lines changed
  • compiler/rustc_hir_pretty/src

1 file changed

+23
-17
lines changed

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,25 +1085,31 @@ impl<'a> State<'a> {
10851085
self.print_qpath(qpath, true);
10861086
self.word("{");
10871087
self.commasep_cmnt(Consistent, fields, |s, field| s.print_expr_field(field), |f| f.span);
1088-
if let hir::StructTailExpr::Base(expr) = wth {
1089-
self.ibox(INDENT_UNIT);
1090-
if !fields.is_empty() {
1091-
self.word(",");
1092-
self.space();
1088+
match wth {
1089+
hir::StructTailExpr::Base(expr) => {
1090+
self.ibox(INDENT_UNIT);
1091+
if !fields.is_empty() {
1092+
self.word(",");
1093+
self.space();
1094+
}
1095+
self.word("..");
1096+
self.print_expr(expr);
1097+
self.end();
10931098
}
1094-
self.word("..");
1095-
self.print_expr(expr);
1096-
self.end();
1097-
} else if let hir::StructTailExpr::DefaultFields(_) = wth {
1098-
self.ibox(INDENT_UNIT);
1099-
if !fields.is_empty() {
1100-
self.word(",");
1101-
self.space();
1099+
hir::StructTailExpr::DefaultFields(_) => {
1100+
self.ibox(INDENT_UNIT);
1101+
if !fields.is_empty() {
1102+
self.word(",");
1103+
self.space();
1104+
}
1105+
self.word("..");
1106+
self.end();
1107+
}
1108+
hir::StructTailExpr::None => {
1109+
if !fields.is_empty() {
1110+
self.word(",");
1111+
}
11021112
}
1103-
self.word("..");
1104-
self.end();
1105-
} else if !fields.is_empty() {
1106-
self.word(",");
11071113
}
11081114

11091115
self.word("}");

0 commit comments

Comments
 (0)