Skip to content

Commit 76625eb

Browse files
committed
or-patterns: syntax: adjust derive, format, and building.
1 parent 424492a commit 76625eb

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

src/libsyntax/ext/build.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,9 @@ impl<'a> ExtCtxt<'a> {
537537
let err_expr = self.expr(sp, ast::ExprKind::Ret(Some(err_inner_expr)));
538538

539539
// `Ok(__try_var) => __try_var`
540-
let ok_arm = self.arm(sp, vec![ok_pat], binding_expr);
540+
let ok_arm = self.arm(sp, ok_pat, binding_expr);
541541
// `Err(__try_var) => return Err(__try_var)`
542-
let err_arm = self.arm(sp, vec![err_pat], err_expr);
542+
let err_arm = self.arm(sp, err_pat, err_expr);
543543

544544
// `match head { Ok() => ..., Err() => ... }`
545545
self.expr_match(sp, head, vec![ok_arm, err_arm])
@@ -606,10 +606,10 @@ impl<'a> ExtCtxt<'a> {
606606
self.pat_tuple_struct(span, path, vec![pat])
607607
}
608608

609-
pub fn arm(&self, span: Span, pats: Vec<P<ast::Pat>>, expr: P<ast::Expr>) -> ast::Arm {
609+
pub fn arm(&self, span: Span, pat: P<ast::Pat>, expr: P<ast::Expr>) -> ast::Arm {
610610
ast::Arm {
611611
attrs: vec![],
612-
pats,
612+
pat,
613613
guard: None,
614614
body: expr,
615615
span,
@@ -618,7 +618,7 @@ impl<'a> ExtCtxt<'a> {
618618
}
619619

620620
pub fn arm_unreachable(&self, span: Span) -> ast::Arm {
621-
self.arm(span, vec![self.pat_wild(span)], self.expr_unreachable(span))
621+
self.arm(span, self.pat_wild(span), self.expr_unreachable(span))
622622
}
623623

624624
pub fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm>) -> P<Expr> {

src/libsyntax_ext/deriving/cmp/ord.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,9 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
9595
cx.expr_call_global(span, cmp_path.clone(), args)
9696
};
9797

98-
let eq_arm = cx.arm(span,
99-
vec![cx.pat_path(span, equals_path.clone())],
100-
old);
98+
let eq_arm = cx.arm(span, cx.pat_path(span, equals_path.clone()), old);
10199
let neq_arm = cx.arm(span,
102-
vec![cx.pat_ident(span, test_id)],
100+
cx.pat_ident(span, test_id),
103101
cx.expr_ident(span, test_id));
104102

105103
cx.expr_match(span, new, vec![eq_arm, neq_arm])

src/libsyntax_ext/deriving/cmp/partial_ord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
160160
};
161161

162162
let eq_arm = cx.arm(span,
163-
vec![cx.pat_some(span, cx.pat_path(span, ordering.clone()))],
163+
cx.pat_some(span, cx.pat_path(span, ordering.clone())),
164164
old);
165165
let neq_arm = cx.arm(span,
166-
vec![cx.pat_ident(span, test_id)],
166+
cx.pat_ident(span, test_id),
167167
cx.expr_ident(span, test_id));
168168

169169
cx.expr_match(span, new, vec![eq_arm, neq_arm])

src/libsyntax_ext/deriving/decodable.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,7 @@ fn decodable_substructure(cx: &mut ExtCtxt<'_>,
119119
vec![idx, exprdecode.clone()]))
120120
});
121121

122-
arms.push(cx.arm(v_span,
123-
vec![cx.pat_lit(v_span, cx.expr_usize(v_span, i))],
124-
decoded));
122+
arms.push(cx.arm(v_span, cx.pat_lit(v_span, cx.expr_usize(v_span, i)), decoded));
125123
}
126124

127125
arms.push(cx.arm_unreachable(trait_span));

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ impl<'a> MethodDef<'a> {
10711071
for (arg_expr, pat) in self_args.iter().zip(patterns) {
10721072
body = cx.expr_match(trait_.span,
10731073
arg_expr.clone(),
1074-
vec![cx.arm(trait_.span, vec![pat.clone()], body)])
1074+
vec![cx.arm(trait_.span, pat.clone(), body)])
10751075
}
10761076

10771077
body
@@ -1311,7 +1311,7 @@ impl<'a> MethodDef<'a> {
13111311
nonself_args,
13121312
&substructure);
13131313

1314-
cx.arm(sp, vec![single_pat], arm_expr)
1314+
cx.arm(sp, single_pat, arm_expr)
13151315
})
13161316
.collect();
13171317

@@ -1337,7 +1337,7 @@ impl<'a> MethodDef<'a> {
13371337
_ => None,
13381338
};
13391339
if let Some(arm) = default {
1340-
match_arms.push(cx.arm(sp, vec![cx.pat_wild(sp)], arm));
1340+
match_arms.push(cx.arm(sp, cx.pat_wild(sp), arm));
13411341
}
13421342

13431343
// We will usually need the catch-all after matching the

src/libsyntax_ext/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ impl<'a, 'b> Context<'a, 'b> {
716716
// But the nested match expression is proved to perform not as well
717717
// as series of let's; the first approach does.
718718
let pat = self.ecx.pat_tuple(self.fmtsp, pats);
719-
let arm = self.ecx.arm(self.fmtsp, vec![pat], args_array);
719+
let arm = self.ecx.arm(self.fmtsp, pat, args_array);
720720
let head = self.ecx.expr(self.fmtsp, ast::ExprKind::Tup(heads));
721721
let result = self.ecx.expr_match(self.fmtsp, head, vec![arm]);
722722

0 commit comments

Comments
 (0)