Skip to content

Commit 549f1c6

Browse files
committed
Use ThinVec in ast::ExprKind::Match.
1 parent 912b825 commit 549f1c6

File tree

8 files changed

+9
-9
lines changed

8 files changed

+9
-9
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ pub enum ExprKind {
14141414
/// `'label: loop { block }`
14151415
Loop(P<Block>, Option<Label>, Span),
14161416
/// A `match` block.
1417-
Match(P<Expr>, Vec<Arm>),
1417+
Match(P<Expr>, ThinVec<Arm>),
14181418
/// A closure (e.g., `move |a, b, c| a + b + c`).
14191419
Closure(Box<Closure>),
14201420
/// A block (`'label: { ... }`).

compiler/rustc_builtin_macros/src/deriving/cmp/ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> Bl
7171
let eq_arm = cx.arm(span, cx.pat_path(span, equal_path.clone()), expr1);
7272
let neq_arm =
7373
cx.arm(span, cx.pat_ident(span, test_id), cx.expr_ident(span, test_id));
74-
cx.expr_match(span, expr2, vec![eq_arm, neq_arm])
74+
cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm])
7575
}
7676
CsFold::Fieldless => cx.expr_path(equal_path.clone()),
7777
},

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn cs_partial_cmp(
143143
cx.arm(span, cx.pat_some(span, cx.pat_path(span, equal_path.clone())), expr1);
144144
let neq_arm =
145145
cx.arm(span, cx.pat_ident(span, test_id), cx.expr_ident(span, test_id));
146-
cx.expr_match(span, expr2, vec![eq_arm, neq_arm])
146+
cx.expr_match(span, expr2, thin_vec![eq_arm, neq_arm])
147147
}
148148
}
149149
CsFold::Fieldless => cx.expr_some(span, cx.expr_path(equal_path.clone())),

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ fn show_fieldless_enum(
234234
};
235235
cx.arm(span, pat, cx.expr_str(span, v.ident.name))
236236
})
237-
.collect::<Vec<_>>();
237+
.collect::<ThinVec<_>>();
238238
let name = cx.expr_match(span, cx.expr_self(span), arms);
239239
let fn_path_write_str = cx.std_path(&[sym::fmt, sym::Formatter, sym::write_str]);
240240
BlockOrExpr::new_expr(cx.expr_call_global(span, fn_path_write_str, thin_vec![fmt, name]))

compiler/rustc_builtin_macros/src/deriving/decodable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ fn decodable_substructure(
123123
StaticEnum(_, fields) => {
124124
let variant = Ident::new(sym::i, trait_span);
125125

126-
let mut arms = Vec::with_capacity(fields.len() + 1);
126+
let mut arms = ThinVec::with_capacity(fields.len() + 1);
127127
let mut variants = ThinVec::with_capacity(fields.len());
128128

129129
let fn_read_enum_variant_arg_path: Vec<_> =

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ impl<'a> MethodDef<'a> {
12471247
// (Variant2, Variant2, ...) => Body2
12481248
// ...
12491249
// where each tuple has length = selflike_args.len()
1250-
let mut match_arms: Vec<ast::Arm> = variants
1250+
let mut match_arms: ThinVec<ast::Arm> = variants
12511251
.iter()
12521252
.enumerate()
12531253
.filter(|&(_, v)| !(unify_fieldless_variants && v.data.fields().is_empty()))

compiler/rustc_expand/src/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ impl<'a> ExtCtxt<'a> {
446446
let err_arm = self.arm(sp, err_pat, err_expr);
447447

448448
// `match head { Ok() => ..., Err() => ... }`
449-
self.expr_match(sp, head, vec![ok_arm, err_arm])
449+
self.expr_match(sp, head, thin_vec![ok_arm, err_arm])
450450
}
451451

452452
pub fn pat(&self, span: Span, kind: PatKind) -> P<ast::Pat> {
@@ -516,7 +516,7 @@ impl<'a> ExtCtxt<'a> {
516516
self.arm(span, self.pat_wild(span), self.expr_unreachable(span))
517517
}
518518

519-
pub fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: Vec<ast::Arm>) -> P<Expr> {
519+
pub fn expr_match(&self, span: Span, arg: P<ast::Expr>, arms: ThinVec<ast::Arm>) -> P<Expr> {
520520
self.expr(span, ast::ExprKind::Match(arg, arms))
521521
}
522522

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,7 @@ impl<'a> Parser<'a> {
25662566
}
25672567
let attrs = self.parse_inner_attributes()?;
25682568

2569-
let mut arms: Vec<Arm> = Vec::new();
2569+
let mut arms = ThinVec::new();
25702570
while self.token != token::CloseDelim(Delimiter::Brace) {
25712571
match self.parse_arm() {
25722572
Ok(arm) => arms.push(arm),

0 commit comments

Comments
 (0)