mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
Use ThinVec
in ast::WhereClause
.
This commit is contained in:
parent
dd7aff5cc5
commit
068db466e8
@ -403,13 +403,13 @@ pub struct WhereClause {
|
||||
/// if we parsed no predicates (e.g. `struct Foo where {}`).
|
||||
/// This allows us to pretty-print accurately.
|
||||
pub has_where_token: bool,
|
||||
pub predicates: Vec<WherePredicate>,
|
||||
pub predicates: ThinVec<WherePredicate>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Default for WhereClause {
|
||||
fn default() -> WhereClause {
|
||||
WhereClause { has_where_token: false, predicates: Vec::new(), span: DUMMY_SP }
|
||||
WhereClause { has_where_token: false, predicates: ThinVec::new(), span: DUMMY_SP }
|
||||
}
|
||||
}
|
||||
|
||||
@ -3115,15 +3115,15 @@ mod size_asserts {
|
||||
static_assert_size!(Block, 48);
|
||||
static_assert_size!(Expr, 72);
|
||||
static_assert_size!(ExprKind, 40);
|
||||
static_assert_size!(Fn, 168);
|
||||
static_assert_size!(Fn, 152);
|
||||
static_assert_size!(ForeignItem, 96);
|
||||
static_assert_size!(ForeignItemKind, 24);
|
||||
static_assert_size!(GenericArg, 24);
|
||||
static_assert_size!(GenericBound, 56);
|
||||
static_assert_size!(Generics, 56);
|
||||
static_assert_size!(Impl, 168);
|
||||
static_assert_size!(Item, 168);
|
||||
static_assert_size!(ItemKind, 96);
|
||||
static_assert_size!(Generics, 40);
|
||||
static_assert_size!(Impl, 152);
|
||||
static_assert_size!(Item, 152);
|
||||
static_assert_size!(ItemKind, 80);
|
||||
static_assert_size!(LitKind, 24);
|
||||
static_assert_size!(Local, 72);
|
||||
static_assert_size!(MetaItemLit, 40);
|
||||
|
@ -17,10 +17,10 @@ use rustc_data_structures::sync::Lrc;
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::Span;
|
||||
|
||||
use smallvec::{smallvec, Array, SmallVec};
|
||||
use std::ops::DerefMut;
|
||||
use std::{panic, ptr};
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
pub trait ExpectOne<A: Array> {
|
||||
fn expect_one(self, err: &'static str) -> A::Item;
|
||||
@ -335,6 +335,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
|
||||
#[inline]
|
||||
pub fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
|
||||
where
|
||||
F: FnMut(&mut T),
|
||||
{
|
||||
for elem in elems {
|
||||
visit_elem(elem);
|
||||
}
|
||||
}
|
||||
|
||||
// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
|
||||
#[inline]
|
||||
pub fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
|
||||
@ -917,7 +928,7 @@ pub fn noop_visit_generics<T: MutVisitor>(generics: &mut Generics, vis: &mut T)
|
||||
|
||||
pub fn noop_visit_where_clause<T: MutVisitor>(wc: &mut WhereClause, vis: &mut T) {
|
||||
let WhereClause { has_where_token: _, predicates, span } = wc;
|
||||
visit_vec(predicates, |predicate| vis.visit_where_predicate(predicate));
|
||||
visit_thin_vec(predicates, |predicate| vis.visit_where_predicate(predicate));
|
||||
vis.visit_span(span);
|
||||
}
|
||||
|
||||
|
@ -1724,7 +1724,7 @@ impl<'a> State<'a> {
|
||||
params: ThinVec::new(),
|
||||
where_clause: ast::WhereClause {
|
||||
has_where_token: false,
|
||||
predicates: Vec::new(),
|
||||
predicates: ThinVec::new(),
|
||||
span: DUMMY_SP,
|
||||
},
|
||||
span: DUMMY_SP,
|
||||
|
@ -9,6 +9,7 @@ use rustc_expand::base::ExtCtxt;
|
||||
use rustc_span::source_map::{respan, DUMMY_SP};
|
||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
|
||||
/// for type parameters.
|
||||
@ -185,7 +186,11 @@ impl Bounds {
|
||||
|
||||
Generics {
|
||||
params,
|
||||
where_clause: ast::WhereClause { has_where_token: false, predicates: Vec::new(), span },
|
||||
where_clause: ast::WhereClause {
|
||||
has_where_token: false,
|
||||
predicates: ThinVec::new(),
|
||||
span,
|
||||
},
|
||||
span,
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ impl<'a> Parser<'a> {
|
||||
params,
|
||||
where_clause: WhereClause {
|
||||
has_where_token: false,
|
||||
predicates: Vec::new(),
|
||||
predicates: ThinVec::new(),
|
||||
span: self.prev_token.span.shrink_to_hi(),
|
||||
},
|
||||
span,
|
||||
@ -288,7 +288,7 @@ impl<'a> Parser<'a> {
|
||||
) -> PResult<'a, (WhereClause, Option<Vec<ast::FieldDef>>)> {
|
||||
let mut where_clause = WhereClause {
|
||||
has_where_token: false,
|
||||
predicates: Vec::new(),
|
||||
predicates: ThinVec::new(),
|
||||
span: self.prev_token.span.shrink_to_hi(),
|
||||
};
|
||||
let mut tuple_struct_body = None;
|
||||
|
@ -8,52 +8,52 @@ ast-stats-1 GenericArgs 56 ( 0.8%) 1 56
|
||||
ast-stats-1 - AngleBracketed 56 ( 0.8%) 1
|
||||
ast-stats-1 Crate 56 ( 0.8%) 1 56
|
||||
ast-stats-1 Attribute 64 ( 0.9%) 2 32
|
||||
ast-stats-1 - Normal 32 ( 0.4%) 1
|
||||
ast-stats-1 - DocComment 32 ( 0.4%) 1
|
||||
ast-stats-1 - Normal 32 ( 0.5%) 1
|
||||
ast-stats-1 - DocComment 32 ( 0.5%) 1
|
||||
ast-stats-1 Local 72 ( 1.0%) 1 72
|
||||
ast-stats-1 Arm 96 ( 1.3%) 2 48
|
||||
ast-stats-1 ForeignItem 96 ( 1.3%) 1 96
|
||||
ast-stats-1 - Fn 96 ( 1.3%) 1
|
||||
ast-stats-1 FieldDef 160 ( 2.2%) 2 80
|
||||
ast-stats-1 Stmt 160 ( 2.2%) 5 32
|
||||
ast-stats-1 - Local 32 ( 0.4%) 1
|
||||
ast-stats-1 - MacCall 32 ( 0.4%) 1
|
||||
ast-stats-1 - Expr 96 ( 1.3%) 3
|
||||
ast-stats-1 Param 160 ( 2.2%) 4 40
|
||||
ast-stats-1 Arm 96 ( 1.4%) 2 48
|
||||
ast-stats-1 ForeignItem 96 ( 1.4%) 1 96
|
||||
ast-stats-1 - Fn 96 ( 1.4%) 1
|
||||
ast-stats-1 FieldDef 160 ( 2.3%) 2 80
|
||||
ast-stats-1 Stmt 160 ( 2.3%) 5 32
|
||||
ast-stats-1 - Local 32 ( 0.5%) 1
|
||||
ast-stats-1 - MacCall 32 ( 0.5%) 1
|
||||
ast-stats-1 - Expr 96 ( 1.4%) 3
|
||||
ast-stats-1 Param 160 ( 2.3%) 4 40
|
||||
ast-stats-1 FnDecl 200 ( 2.8%) 5 40
|
||||
ast-stats-1 GenericBound 224 ( 3.1%) 4 56
|
||||
ast-stats-1 - Trait 224 ( 3.1%) 4
|
||||
ast-stats-1 Variant 240 ( 3.3%) 2 120
|
||||
ast-stats-1 Block 288 ( 4.0%) 6 48
|
||||
ast-stats-1 AssocItem 416 ( 5.8%) 4 104
|
||||
ast-stats-1 - Type 208 ( 2.9%) 2
|
||||
ast-stats-1 - Fn 208 ( 2.9%) 2
|
||||
ast-stats-1 GenericParam 480 ( 6.7%) 5 96
|
||||
ast-stats-1 Expr 576 ( 8.0%) 8 72
|
||||
ast-stats-1 GenericBound 224 ( 3.2%) 4 56
|
||||
ast-stats-1 - Trait 224 ( 3.2%) 4
|
||||
ast-stats-1 Variant 240 ( 3.4%) 2 120
|
||||
ast-stats-1 Block 288 ( 4.1%) 6 48
|
||||
ast-stats-1 AssocItem 416 ( 5.9%) 4 104
|
||||
ast-stats-1 - Type 208 ( 3.0%) 2
|
||||
ast-stats-1 - Fn 208 ( 3.0%) 2
|
||||
ast-stats-1 GenericParam 480 ( 6.8%) 5 96
|
||||
ast-stats-1 Expr 576 ( 8.2%) 8 72
|
||||
ast-stats-1 - Path 72 ( 1.0%) 1
|
||||
ast-stats-1 - Match 72 ( 1.0%) 1
|
||||
ast-stats-1 - Struct 72 ( 1.0%) 1
|
||||
ast-stats-1 - Lit 144 ( 2.0%) 2
|
||||
ast-stats-1 - Block 216 ( 3.0%) 3
|
||||
ast-stats-1 Pat 616 ( 8.6%) 7 88
|
||||
ast-stats-1 - Block 216 ( 3.1%) 3
|
||||
ast-stats-1 Pat 616 ( 8.7%) 7 88
|
||||
ast-stats-1 - Struct 88 ( 1.2%) 1
|
||||
ast-stats-1 - Wild 88 ( 1.2%) 1
|
||||
ast-stats-1 - Ident 440 ( 6.1%) 5
|
||||
ast-stats-1 PathSegment 720 (10.0%) 30 24
|
||||
ast-stats-1 Ty 896 (12.5%) 14 64
|
||||
ast-stats-1 - Ident 440 ( 6.2%) 5
|
||||
ast-stats-1 PathSegment 720 (10.2%) 30 24
|
||||
ast-stats-1 Ty 896 (12.7%) 14 64
|
||||
ast-stats-1 - Ptr 64 ( 0.9%) 1
|
||||
ast-stats-1 - Ref 64 ( 0.9%) 1
|
||||
ast-stats-1 - ImplicitSelf 128 ( 1.8%) 2
|
||||
ast-stats-1 - Path 640 ( 8.9%) 10
|
||||
ast-stats-1 Item 1_512 (21.0%) 9 168
|
||||
ast-stats-1 - Trait 168 ( 2.3%) 1
|
||||
ast-stats-1 - Enum 168 ( 2.3%) 1
|
||||
ast-stats-1 - ForeignMod 168 ( 2.3%) 1
|
||||
ast-stats-1 - Impl 168 ( 2.3%) 1
|
||||
ast-stats-1 - Fn 336 ( 4.7%) 2
|
||||
ast-stats-1 - Use 504 ( 7.0%) 3
|
||||
ast-stats-1 - Path 640 ( 9.1%) 10
|
||||
ast-stats-1 Item 1_368 (19.4%) 9 152
|
||||
ast-stats-1 - Trait 152 ( 2.2%) 1
|
||||
ast-stats-1 - Enum 152 ( 2.2%) 1
|
||||
ast-stats-1 - ForeignMod 152 ( 2.2%) 1
|
||||
ast-stats-1 - Impl 152 ( 2.2%) 1
|
||||
ast-stats-1 - Fn 304 ( 4.3%) 2
|
||||
ast-stats-1 - Use 456 ( 6.5%) 3
|
||||
ast-stats-1 ----------------------------------------------------------------
|
||||
ast-stats-1 Total 7_192
|
||||
ast-stats-1 Total 7_048
|
||||
ast-stats-1
|
||||
ast-stats-2 POST EXPANSION AST STATS
|
||||
ast-stats-2 Name Accumulated Size Count Item Size
|
||||
@ -68,52 +68,52 @@ ast-stats-2 Local 72 ( 0.9%) 1 72
|
||||
ast-stats-2 Arm 96 ( 1.2%) 2 48
|
||||
ast-stats-2 ForeignItem 96 ( 1.2%) 1 96
|
||||
ast-stats-2 - Fn 96 ( 1.2%) 1
|
||||
ast-stats-2 InlineAsm 120 ( 1.5%) 1 120
|
||||
ast-stats-2 Attribute 128 ( 1.6%) 4 32
|
||||
ast-stats-2 InlineAsm 120 ( 1.6%) 1 120
|
||||
ast-stats-2 Attribute 128 ( 1.7%) 4 32
|
||||
ast-stats-2 - DocComment 32 ( 0.4%) 1
|
||||
ast-stats-2 - Normal 96 ( 1.2%) 3
|
||||
ast-stats-2 FieldDef 160 ( 2.0%) 2 80
|
||||
ast-stats-2 Stmt 160 ( 2.0%) 5 32
|
||||
ast-stats-2 FieldDef 160 ( 2.1%) 2 80
|
||||
ast-stats-2 Stmt 160 ( 2.1%) 5 32
|
||||
ast-stats-2 - Local 32 ( 0.4%) 1
|
||||
ast-stats-2 - Semi 32 ( 0.4%) 1
|
||||
ast-stats-2 - Expr 96 ( 1.2%) 3
|
||||
ast-stats-2 Param 160 ( 2.0%) 4 40
|
||||
ast-stats-2 FnDecl 200 ( 2.5%) 5 40
|
||||
ast-stats-2 Param 160 ( 2.1%) 4 40
|
||||
ast-stats-2 FnDecl 200 ( 2.6%) 5 40
|
||||
ast-stats-2 GenericBound 224 ( 2.9%) 4 56
|
||||
ast-stats-2 - Trait 224 ( 2.9%) 4
|
||||
ast-stats-2 Variant 240 ( 3.1%) 2 120
|
||||
ast-stats-2 Block 288 ( 3.7%) 6 48
|
||||
ast-stats-2 AssocItem 416 ( 5.3%) 4 104
|
||||
ast-stats-2 - Type 208 ( 2.6%) 2
|
||||
ast-stats-2 - Fn 208 ( 2.6%) 2
|
||||
ast-stats-2 GenericParam 480 ( 6.1%) 5 96
|
||||
ast-stats-2 Pat 616 ( 7.8%) 7 88
|
||||
ast-stats-2 Block 288 ( 3.8%) 6 48
|
||||
ast-stats-2 AssocItem 416 ( 5.4%) 4 104
|
||||
ast-stats-2 - Type 208 ( 2.7%) 2
|
||||
ast-stats-2 - Fn 208 ( 2.7%) 2
|
||||
ast-stats-2 GenericParam 480 ( 6.2%) 5 96
|
||||
ast-stats-2 Pat 616 ( 8.0%) 7 88
|
||||
ast-stats-2 - Struct 88 ( 1.1%) 1
|
||||
ast-stats-2 - Wild 88 ( 1.1%) 1
|
||||
ast-stats-2 - Ident 440 ( 5.6%) 5
|
||||
ast-stats-2 Expr 648 ( 8.2%) 9 72
|
||||
ast-stats-2 - Ident 440 ( 5.7%) 5
|
||||
ast-stats-2 Expr 648 ( 8.4%) 9 72
|
||||
ast-stats-2 - Path 72 ( 0.9%) 1
|
||||
ast-stats-2 - Match 72 ( 0.9%) 1
|
||||
ast-stats-2 - Struct 72 ( 0.9%) 1
|
||||
ast-stats-2 - InlineAsm 72 ( 0.9%) 1
|
||||
ast-stats-2 - Lit 144 ( 1.8%) 2
|
||||
ast-stats-2 - Block 216 ( 2.7%) 3
|
||||
ast-stats-2 PathSegment 792 (10.1%) 33 24
|
||||
ast-stats-2 Ty 896 (11.4%) 14 64
|
||||
ast-stats-2 - Lit 144 ( 1.9%) 2
|
||||
ast-stats-2 - Block 216 ( 2.8%) 3
|
||||
ast-stats-2 PathSegment 792 (10.3%) 33 24
|
||||
ast-stats-2 Ty 896 (11.7%) 14 64
|
||||
ast-stats-2 - Ptr 64 ( 0.8%) 1
|
||||
ast-stats-2 - Ref 64 ( 0.8%) 1
|
||||
ast-stats-2 - ImplicitSelf 128 ( 1.6%) 2
|
||||
ast-stats-2 - Path 640 ( 8.1%) 10
|
||||
ast-stats-2 Item 1_848 (23.5%) 11 168
|
||||
ast-stats-2 - Trait 168 ( 2.1%) 1
|
||||
ast-stats-2 - Enum 168 ( 2.1%) 1
|
||||
ast-stats-2 - ExternCrate 168 ( 2.1%) 1
|
||||
ast-stats-2 - ForeignMod 168 ( 2.1%) 1
|
||||
ast-stats-2 - Impl 168 ( 2.1%) 1
|
||||
ast-stats-2 - Fn 336 ( 4.3%) 2
|
||||
ast-stats-2 - Use 672 ( 8.6%) 4
|
||||
ast-stats-2 - ImplicitSelf 128 ( 1.7%) 2
|
||||
ast-stats-2 - Path 640 ( 8.3%) 10
|
||||
ast-stats-2 Item 1_672 (21.8%) 11 152
|
||||
ast-stats-2 - Trait 152 ( 2.0%) 1
|
||||
ast-stats-2 - Enum 152 ( 2.0%) 1
|
||||
ast-stats-2 - ExternCrate 152 ( 2.0%) 1
|
||||
ast-stats-2 - ForeignMod 152 ( 2.0%) 1
|
||||
ast-stats-2 - Impl 152 ( 2.0%) 1
|
||||
ast-stats-2 - Fn 304 ( 4.0%) 2
|
||||
ast-stats-2 - Use 608 ( 7.9%) 4
|
||||
ast-stats-2 ----------------------------------------------------------------
|
||||
ast-stats-2 Total 7_856
|
||||
ast-stats-2 Total 7_680
|
||||
ast-stats-2
|
||||
hir-stats HIR STATS
|
||||
hir-stats Name Accumulated Size Count Item Size
|
||||
|
Loading…
Reference in New Issue
Block a user