or-patterns: syntax: adjust derive, format, and building.

This commit is contained in:
Mazdak Farrokhzad
2019-08-28 01:16:35 +02:00
parent 424492acc8
commit 76625eb0cc
6 changed files with 14 additions and 18 deletions

View File

@@ -95,11 +95,9 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P<
cx.expr_call_global(span, cmp_path.clone(), args)
};
let eq_arm = cx.arm(span,
vec![cx.pat_path(span, equals_path.clone())],
old);
let eq_arm = cx.arm(span, cx.pat_path(span, equals_path.clone()), old);
let neq_arm = cx.arm(span,
vec![cx.pat_ident(span, test_id)],
cx.pat_ident(span, test_id),
cx.expr_ident(span, test_id));
cx.expr_match(span, new, vec![eq_arm, neq_arm])

View File

@@ -160,10 +160,10 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_
};
let eq_arm = cx.arm(span,
vec![cx.pat_some(span, cx.pat_path(span, ordering.clone()))],
cx.pat_some(span, cx.pat_path(span, ordering.clone())),
old);
let neq_arm = cx.arm(span,
vec![cx.pat_ident(span, test_id)],
cx.pat_ident(span, test_id),
cx.expr_ident(span, test_id));
cx.expr_match(span, new, vec![eq_arm, neq_arm])

View File

@@ -119,9 +119,7 @@ fn decodable_substructure(cx: &mut ExtCtxt<'_>,
vec![idx, exprdecode.clone()]))
});
arms.push(cx.arm(v_span,
vec![cx.pat_lit(v_span, cx.expr_usize(v_span, i))],
decoded));
arms.push(cx.arm(v_span, cx.pat_lit(v_span, cx.expr_usize(v_span, i)), decoded));
}
arms.push(cx.arm_unreachable(trait_span));

View File

@@ -1071,7 +1071,7 @@ impl<'a> MethodDef<'a> {
for (arg_expr, pat) in self_args.iter().zip(patterns) {
body = cx.expr_match(trait_.span,
arg_expr.clone(),
vec![cx.arm(trait_.span, vec![pat.clone()], body)])
vec![cx.arm(trait_.span, pat.clone(), body)])
}
body
@@ -1311,7 +1311,7 @@ impl<'a> MethodDef<'a> {
nonself_args,
&substructure);
cx.arm(sp, vec![single_pat], arm_expr)
cx.arm(sp, single_pat, arm_expr)
})
.collect();
@@ -1337,7 +1337,7 @@ impl<'a> MethodDef<'a> {
_ => None,
};
if let Some(arm) = default {
match_arms.push(cx.arm(sp, vec![cx.pat_wild(sp)], arm));
match_arms.push(cx.arm(sp, cx.pat_wild(sp), arm));
}
// We will usually need the catch-all after matching the

View File

@@ -716,7 +716,7 @@ impl<'a, 'b> Context<'a, 'b> {
// But the nested match expression is proved to perform not as well
// as series of let's; the first approach does.
let pat = self.ecx.pat_tuple(self.fmtsp, pats);
let arm = self.ecx.arm(self.fmtsp, vec![pat], args_array);
let arm = self.ecx.arm(self.fmtsp, pat, args_array);
let head = self.ecx.expr(self.fmtsp, ast::ExprKind::Tup(heads));
let result = self.ecx.expr_match(self.fmtsp, head, vec![arm]);