Skip to content

Commit 912b825

Browse files
committed
Use ThinVec in ast::PatKind::Struct.
1 parent 1807027 commit 912b825

File tree

5 files changed

+61
-61
lines changed

5 files changed

+61
-61
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ pub enum PatKind {
722722

723723
/// A struct or struct variant pattern (e.g., `Variant {x, y, ..}`).
724724
/// The `bool` is `true` in the presence of a `..`.
725-
Struct(Option<P<QSelf>>, Path, Vec<PatField>, /* recovered */ bool),
725+
Struct(Option<P<QSelf>>, Path, ThinVec<PatField>, /* recovered */ bool),
726726

727727
/// A tuple struct/variant pattern (`Variant(x, y, .., z)`).
728728
TupleStruct(Option<P<QSelf>>, Path, ThinVec<P<Pat>>),
@@ -3128,10 +3128,10 @@ mod size_asserts {
31283128
static_assert_size!(Local, 72);
31293129
static_assert_size!(MetaItemLit, 40);
31303130
static_assert_size!(Param, 40);
3131-
static_assert_size!(Pat, 88);
3131+
static_assert_size!(Pat, 72);
31323132
static_assert_size!(Path, 24);
31333133
static_assert_size!(PathSegment, 24);
3134-
static_assert_size!(PatKind, 64);
3134+
static_assert_size!(PatKind, 48);
31353135
static_assert_size!(Stmt, 32);
31363136
static_assert_size!(StmtKind, 16);
31373137
static_assert_size!(Ty, 64);

compiler/rustc_builtin_macros/src/deriving/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ fn show_fieldless_enum(
224224
let pat = match &v.data {
225225
ast::VariantData::Tuple(fields, _) => {
226226
debug_assert!(fields.is_empty());
227-
cx.pat_tuple_struct(span, variant_path, thin_vec![])
227+
cx.pat_tuple_struct(span, variant_path, ThinVec::new())
228228
}
229229
ast::VariantData::Struct(fields, _) => {
230230
debug_assert!(fields.is_empty());
231-
cx.pat_struct(span, variant_path, vec![])
231+
cx.pat_struct(span, variant_path, ThinVec::new())
232232
}
233233
ast::VariantData::Unit(_) => cx.pat_path(span, variant_path),
234234
};

compiler/rustc_expand/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl<'a> ExtCtxt<'a> {
486486
&self,
487487
span: Span,
488488
path: ast::Path,
489-
field_pats: Vec<ast::PatField>,
489+
field_pats: ThinVec<ast::PatField>,
490490
) -> P<ast::Pat> {
491491
self.pat(span, PatKind::Struct(None, path, field_pats, false))
492492
}

compiler/rustc_parse/src/parser/pat.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rustc_errors::{
2323
use rustc_session::errors::ExprParenthesesNeeded;
2424
use rustc_span::source_map::{respan, Span, Spanned};
2525
use rustc_span::symbol::{kw, sym, Ident};
26-
use thin_vec::thin_vec;
26+
use thin_vec::{thin_vec, ThinVec};
2727

2828
#[derive(PartialEq, Copy, Clone)]
2929
pub enum Expected {
@@ -854,7 +854,7 @@ impl<'a> Parser<'a> {
854854
e.span_label(path.span, "while parsing the fields for this pattern");
855855
e.emit();
856856
self.recover_stmt();
857-
(vec![], true)
857+
(ThinVec::new(), true)
858858
});
859859
self.bump();
860860
Ok(PatKind::Struct(qself, path, fields, etc))
@@ -933,8 +933,8 @@ impl<'a> Parser<'a> {
933933
}
934934

935935
/// Parses the fields of a struct-like pattern.
936-
fn parse_pat_fields(&mut self) -> PResult<'a, (Vec<PatField>, bool)> {
937-
let mut fields = Vec::new();
936+
fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, bool)> {
937+
let mut fields = ThinVec::new();
938938
let mut etc = false;
939939
let mut ate_comma = true;
940940
let mut delayed_err: Option<DiagnosticBuilder<'a, ErrorGuaranteed>> = None;

tests/ui/stats/hir-stats.stderr

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ast-stats-1 ExprField 48 ( 0.7%) 1 48
77
ast-stats-1 WherePredicate 56 ( 0.8%) 1 56
88
ast-stats-1 - BoundPredicate 56 ( 0.8%) 1
99
ast-stats-1 Crate 56 ( 0.8%) 1 56
10-
ast-stats-1 Attribute 64 ( 0.9%) 2 32
10+
ast-stats-1 Attribute 64 ( 1.0%) 2 32
1111
ast-stats-1 - Normal 32 ( 0.5%) 1
1212
ast-stats-1 - DocComment 32 ( 0.5%) 1
1313
ast-stats-1 Local 72 ( 1.1%) 1 72
@@ -21,45 +21,45 @@ ast-stats-1 - Local 32 ( 0.5%) 1
2121
ast-stats-1 - MacCall 32 ( 0.5%) 1
2222
ast-stats-1 - Expr 96 ( 1.4%) 3
2323
ast-stats-1 Param 160 ( 2.4%) 4 40
24-
ast-stats-1 Block 192 ( 2.8%) 6 32
24+
ast-stats-1 Block 192 ( 2.9%) 6 32
2525
ast-stats-1 Variant 208 ( 3.1%) 2 104
26-
ast-stats-1 GenericBound 224 ( 3.3%) 4 56
27-
ast-stats-1 - Trait 224 ( 3.3%) 4
28-
ast-stats-1 AssocItem 416 ( 6.2%) 4 104
26+
ast-stats-1 GenericBound 224 ( 3.4%) 4 56
27+
ast-stats-1 - Trait 224 ( 3.4%) 4
28+
ast-stats-1 AssocItem 416 ( 6.3%) 4 104
2929
ast-stats-1 - Type 208 ( 3.1%) 2
3030
ast-stats-1 - Fn 208 ( 3.1%) 2
31-
ast-stats-1 GenericParam 480 ( 7.1%) 5 96
32-
ast-stats-1 Expr 576 ( 8.5%) 8 72
31+
ast-stats-1 GenericParam 480 ( 7.2%) 5 96
32+
ast-stats-1 Pat 504 ( 7.6%) 7 72
33+
ast-stats-1 - Struct 72 ( 1.1%) 1
34+
ast-stats-1 - Wild 72 ( 1.1%) 1
35+
ast-stats-1 - Ident 360 ( 5.4%) 5
36+
ast-stats-1 Expr 576 ( 8.7%) 8 72
3337
ast-stats-1 - Path 72 ( 1.1%) 1
3438
ast-stats-1 - Match 72 ( 1.1%) 1
3539
ast-stats-1 - Struct 72 ( 1.1%) 1
36-
ast-stats-1 - Lit 144 ( 2.1%) 2
37-
ast-stats-1 - Block 216 ( 3.2%) 3
38-
ast-stats-1 Pat 616 ( 9.1%) 7 88
39-
ast-stats-1 - Struct 88 ( 1.3%) 1
40-
ast-stats-1 - Wild 88 ( 1.3%) 1
41-
ast-stats-1 - Ident 440 ( 6.5%) 5
42-
ast-stats-1 PathSegment 720 (10.7%) 30 24
43-
ast-stats-1 Ty 896 (13.3%) 14 64
44-
ast-stats-1 - Ptr 64 ( 0.9%) 1
45-
ast-stats-1 - Ref 64 ( 0.9%) 1
40+
ast-stats-1 - Lit 144 ( 2.2%) 2
41+
ast-stats-1 - Block 216 ( 3.3%) 3
42+
ast-stats-1 PathSegment 720 (10.8%) 30 24
43+
ast-stats-1 Ty 896 (13.5%) 14 64
44+
ast-stats-1 - Ptr 64 ( 1.0%) 1
45+
ast-stats-1 - Ref 64 ( 1.0%) 1
4646
ast-stats-1 - ImplicitSelf 128 ( 1.9%) 2
47-
ast-stats-1 - Path 640 ( 9.5%) 10
48-
ast-stats-1 Item 1_296 (19.2%) 9 144
49-
ast-stats-1 - Trait 144 ( 2.1%) 1
50-
ast-stats-1 - Enum 144 ( 2.1%) 1
51-
ast-stats-1 - ForeignMod 144 ( 2.1%) 1
52-
ast-stats-1 - Impl 144 ( 2.1%) 1
47+
ast-stats-1 - Path 640 ( 9.6%) 10
48+
ast-stats-1 Item 1_296 (19.5%) 9 144
49+
ast-stats-1 - Trait 144 ( 2.2%) 1
50+
ast-stats-1 - Enum 144 ( 2.2%) 1
51+
ast-stats-1 - ForeignMod 144 ( 2.2%) 1
52+
ast-stats-1 - Impl 144 ( 2.2%) 1
5353
ast-stats-1 - Fn 288 ( 4.3%) 2
54-
ast-stats-1 - Use 432 ( 6.4%) 3
54+
ast-stats-1 - Use 432 ( 6.5%) 3
5555
ast-stats-1 ----------------------------------------------------------------
56-
ast-stats-1 Total 6_752
56+
ast-stats-1 Total 6_640
5757
ast-stats-1
5858
ast-stats-2 POST EXPANSION AST STATS
5959
ast-stats-2 Name Accumulated Size Count Item Size
6060
ast-stats-2 ----------------------------------------------------------------
61-
ast-stats-2 GenericArgs 40 ( 0.5%) 1 40
62-
ast-stats-2 - AngleBracketed 40 ( 0.5%) 1
61+
ast-stats-2 GenericArgs 40 ( 0.6%) 1 40
62+
ast-stats-2 - AngleBracketed 40 ( 0.6%) 1
6363
ast-stats-2 ExprField 48 ( 0.7%) 1 48
6464
ast-stats-2 WherePredicate 56 ( 0.8%) 1 56
6565
ast-stats-2 - BoundPredicate 56 ( 0.8%) 1
@@ -68,9 +68,9 @@ ast-stats-2 Local 72 ( 1.0%) 1 72
6868
ast-stats-2 Arm 96 ( 1.3%) 2 48
6969
ast-stats-2 ForeignItem 96 ( 1.3%) 1 96
7070
ast-stats-2 - Fn 96 ( 1.3%) 1
71-
ast-stats-2 InlineAsm 120 ( 1.6%) 1 120
72-
ast-stats-2 FnDecl 120 ( 1.6%) 5 24
73-
ast-stats-2 Attribute 128 ( 1.7%) 4 32
71+
ast-stats-2 InlineAsm 120 ( 1.7%) 1 120
72+
ast-stats-2 FnDecl 120 ( 1.7%) 5 24
73+
ast-stats-2 Attribute 128 ( 1.8%) 4 32
7474
ast-stats-2 - DocComment 32 ( 0.4%) 1
7575
ast-stats-2 - Normal 96 ( 1.3%) 3
7676
ast-stats-2 FieldDef 160 ( 2.2%) 2 80
@@ -80,40 +80,40 @@ ast-stats-2 - Semi 32 ( 0.4%) 1
8080
ast-stats-2 - Expr 96 ( 1.3%) 3
8181
ast-stats-2 Param 160 ( 2.2%) 4 40
8282
ast-stats-2 Block 192 ( 2.6%) 6 32
83-
ast-stats-2 Variant 208 ( 2.8%) 2 104
84-
ast-stats-2 GenericBound 224 ( 3.0%) 4 56
85-
ast-stats-2 - Trait 224 ( 3.0%) 4
86-
ast-stats-2 AssocItem 416 ( 5.6%) 4 104
87-
ast-stats-2 - Type 208 ( 2.8%) 2
88-
ast-stats-2 - Fn 208 ( 2.8%) 2
89-
ast-stats-2 GenericParam 480 ( 6.5%) 5 96
90-
ast-stats-2 Pat 616 ( 8.4%) 7 88
91-
ast-stats-2 - Struct 88 ( 1.2%) 1
92-
ast-stats-2 - Wild 88 ( 1.2%) 1
93-
ast-stats-2 - Ident 440 ( 6.0%) 5
94-
ast-stats-2 Expr 648 ( 8.8%) 9 72
83+
ast-stats-2 Variant 208 ( 2.9%) 2 104
84+
ast-stats-2 GenericBound 224 ( 3.1%) 4 56
85+
ast-stats-2 - Trait 224 ( 3.1%) 4
86+
ast-stats-2 AssocItem 416 ( 5.7%) 4 104
87+
ast-stats-2 - Type 208 ( 2.9%) 2
88+
ast-stats-2 - Fn 208 ( 2.9%) 2
89+
ast-stats-2 GenericParam 480 ( 6.6%) 5 96
90+
ast-stats-2 Pat 504 ( 6.9%) 7 72
91+
ast-stats-2 - Struct 72 ( 1.0%) 1
92+
ast-stats-2 - Wild 72 ( 1.0%) 1
93+
ast-stats-2 - Ident 360 ( 5.0%) 5
94+
ast-stats-2 Expr 648 ( 8.9%) 9 72
9595
ast-stats-2 - Path 72 ( 1.0%) 1
9696
ast-stats-2 - Match 72 ( 1.0%) 1
9797
ast-stats-2 - Struct 72 ( 1.0%) 1
9898
ast-stats-2 - InlineAsm 72 ( 1.0%) 1
9999
ast-stats-2 - Lit 144 ( 2.0%) 2
100-
ast-stats-2 - Block 216 ( 2.9%) 3
101-
ast-stats-2 PathSegment 792 (10.7%) 33 24
102-
ast-stats-2 Ty 896 (12.2%) 14 64
100+
ast-stats-2 - Block 216 ( 3.0%) 3
101+
ast-stats-2 PathSegment 792 (10.9%) 33 24
102+
ast-stats-2 Ty 896 (12.3%) 14 64
103103
ast-stats-2 - Ptr 64 ( 0.9%) 1
104104
ast-stats-2 - Ref 64 ( 0.9%) 1
105-
ast-stats-2 - ImplicitSelf 128 ( 1.7%) 2
106-
ast-stats-2 - Path 640 ( 8.7%) 10
107-
ast-stats-2 Item 1_584 (21.5%) 11 144
105+
ast-stats-2 - ImplicitSelf 128 ( 1.8%) 2
106+
ast-stats-2 - Path 640 ( 8.8%) 10
107+
ast-stats-2 Item 1_584 (21.8%) 11 144
108108
ast-stats-2 - Trait 144 ( 2.0%) 1
109109
ast-stats-2 - Enum 144 ( 2.0%) 1
110110
ast-stats-2 - ExternCrate 144 ( 2.0%) 1
111111
ast-stats-2 - ForeignMod 144 ( 2.0%) 1
112112
ast-stats-2 - Impl 144 ( 2.0%) 1
113-
ast-stats-2 - Fn 288 ( 3.9%) 2
114-
ast-stats-2 - Use 576 ( 7.8%) 4
113+
ast-stats-2 - Fn 288 ( 4.0%) 2
114+
ast-stats-2 - Use 576 ( 7.9%) 4
115115
ast-stats-2 ----------------------------------------------------------------
116-
ast-stats-2 Total 7_368
116+
ast-stats-2 Total 7_256
117117
ast-stats-2
118118
hir-stats HIR STATS
119119
hir-stats Name Accumulated Size Count Item Size

0 commit comments

Comments
 (0)