Shrink ast::Attribute
.
This commit is contained in:
parent
40336865fe
commit
85a6cd6a47
15 changed files with 167 additions and 149 deletions
|
@ -2547,10 +2547,16 @@ pub struct Attribute {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||||
|
pub struct NormalAttr {
|
||||||
|
pub item: AttrItem,
|
||||||
|
pub tokens: Option<LazyTokenStream>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||||
pub enum AttrKind {
|
pub enum AttrKind {
|
||||||
/// A normal attribute.
|
/// A normal attribute.
|
||||||
Normal(AttrItem, Option<LazyTokenStream>),
|
Normal(P<NormalAttr>),
|
||||||
|
|
||||||
/// A doc comment (e.g. `/// ...`, `//! ...`, `/** ... */`, `/*! ... */`).
|
/// A doc comment (e.g. `/// ...`, `//! ...`, `/** ... */`, `/*! ... */`).
|
||||||
/// Doc attributes (e.g. `#[doc="..."]`) are represented with the `Normal`
|
/// Doc attributes (e.g. `#[doc="..."]`) are represented with the `Normal`
|
||||||
|
@ -3033,7 +3039,7 @@ mod size_asserts {
|
||||||
// These are in alphabetical order, which is easy to maintain.
|
// These are in alphabetical order, which is easy to maintain.
|
||||||
static_assert_size!(AssocItem, 160);
|
static_assert_size!(AssocItem, 160);
|
||||||
static_assert_size!(AssocItemKind, 72);
|
static_assert_size!(AssocItemKind, 72);
|
||||||
static_assert_size!(Attribute, 152);
|
static_assert_size!(Attribute, 32);
|
||||||
static_assert_size!(Block, 48);
|
static_assert_size!(Block, 48);
|
||||||
static_assert_size!(Expr, 104);
|
static_assert_size!(Expr, 104);
|
||||||
static_assert_size!(Fn, 192);
|
static_assert_size!(Fn, 192);
|
||||||
|
|
|
@ -212,7 +212,7 @@ impl HasTokens for Stmt {
|
||||||
impl HasTokens for Attribute {
|
impl HasTokens for Attribute {
|
||||||
fn tokens(&self) -> Option<&LazyTokenStream> {
|
fn tokens(&self) -> Option<&LazyTokenStream> {
|
||||||
match &self.kind {
|
match &self.kind {
|
||||||
AttrKind::Normal(_, tokens) => tokens.as_ref(),
|
AttrKind::Normal(normal) => normal.tokens.as_ref(),
|
||||||
kind @ AttrKind::DocComment(..) => {
|
kind @ AttrKind::DocComment(..) => {
|
||||||
panic!("Called tokens on doc comment attr {:?}", kind)
|
panic!("Called tokens on doc comment attr {:?}", kind)
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ impl HasTokens for Attribute {
|
||||||
}
|
}
|
||||||
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
|
fn tokens_mut(&mut self) -> Option<&mut Option<LazyTokenStream>> {
|
||||||
Some(match &mut self.kind {
|
Some(match &mut self.kind {
|
||||||
AttrKind::Normal(_, tokens) => tokens,
|
AttrKind::Normal(normal) => &mut normal.tokens,
|
||||||
kind @ AttrKind::DocComment(..) => {
|
kind @ AttrKind::DocComment(..) => {
|
||||||
panic!("Called tokens_mut on doc comment attr {:?}", kind)
|
panic!("Called tokens_mut on doc comment attr {:?}", kind)
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ impl Attribute {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_name(&self, name: Symbol) -> bool {
|
pub fn has_name(&self, name: Symbol) -> bool {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => item.path == name,
|
AttrKind::Normal(ref normal) => normal.item.path == name,
|
||||||
AttrKind::DocComment(..) => false,
|
AttrKind::DocComment(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,9 +122,9 @@ impl Attribute {
|
||||||
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
|
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
|
||||||
pub fn ident(&self) -> Option<Ident> {
|
pub fn ident(&self) -> Option<Ident> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => {
|
AttrKind::Normal(ref normal) => {
|
||||||
if item.path.segments.len() == 1 {
|
if normal.item.path.segments.len() == 1 {
|
||||||
Some(item.path.segments[0].ident)
|
Some(normal.item.path.segments[0].ident)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -138,14 +138,16 @@ impl Attribute {
|
||||||
|
|
||||||
pub fn value_str(&self) -> Option<Symbol> {
|
pub fn value_str(&self) -> Option<Symbol> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => item.meta_kind().and_then(|kind| kind.value_str()),
|
AttrKind::Normal(ref normal) => {
|
||||||
|
normal.item.meta_kind().and_then(|kind| kind.value_str())
|
||||||
|
}
|
||||||
AttrKind::DocComment(..) => None,
|
AttrKind::DocComment(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn meta_item_list(&self) -> Option<Vec<NestedMetaItem>> {
|
pub fn meta_item_list(&self) -> Option<Vec<NestedMetaItem>> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => match item.meta_kind() {
|
AttrKind::Normal(ref normal) => match normal.item.meta_kind() {
|
||||||
Some(MetaItemKind::List(list)) => Some(list),
|
Some(MetaItemKind::List(list)) => Some(list),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
|
@ -154,8 +156,8 @@ impl Attribute {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_word(&self) -> bool {
|
pub fn is_word(&self) -> bool {
|
||||||
if let AttrKind::Normal(item, _) = &self.kind {
|
if let AttrKind::Normal(normal) = &self.kind {
|
||||||
matches!(item.args, MacArgs::Empty)
|
matches!(normal.item.args, MacArgs::Empty)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -247,7 +249,8 @@ impl Attribute {
|
||||||
pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> {
|
pub fn doc_str_and_comment_kind(&self) -> Option<(Symbol, CommentKind)> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::DocComment(kind, data) => Some((data, kind)),
|
AttrKind::DocComment(kind, data) => Some((data, kind)),
|
||||||
AttrKind::Normal(ref item, _) if item.path == sym::doc => item
|
AttrKind::Normal(ref normal) if normal.item.path == sym::doc => normal
|
||||||
|
.item
|
||||||
.meta_kind()
|
.meta_kind()
|
||||||
.and_then(|kind| kind.value_str())
|
.and_then(|kind| kind.value_str())
|
||||||
.map(|data| (data, CommentKind::Line)),
|
.map(|data| (data, CommentKind::Line)),
|
||||||
|
@ -258,8 +261,8 @@ impl Attribute {
|
||||||
pub fn doc_str(&self) -> Option<Symbol> {
|
pub fn doc_str(&self) -> Option<Symbol> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::DocComment(.., data) => Some(data),
|
AttrKind::DocComment(.., data) => Some(data),
|
||||||
AttrKind::Normal(ref item, _) if item.path == sym::doc => {
|
AttrKind::Normal(ref normal) if normal.item.path == sym::doc => {
|
||||||
item.meta_kind().and_then(|kind| kind.value_str())
|
normal.item.meta_kind().and_then(|kind| kind.value_str())
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -271,14 +274,14 @@ impl Attribute {
|
||||||
|
|
||||||
pub fn get_normal_item(&self) -> &AttrItem {
|
pub fn get_normal_item(&self) -> &AttrItem {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => item,
|
AttrKind::Normal(ref normal) => &normal.item,
|
||||||
AttrKind::DocComment(..) => panic!("unexpected doc comment"),
|
AttrKind::DocComment(..) => panic!("unexpected doc comment"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unwrap_normal_item(self) -> AttrItem {
|
pub fn unwrap_normal_item(self) -> AttrItem {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(item, _) => item,
|
AttrKind::Normal(normal) => normal.into_inner().item,
|
||||||
AttrKind::DocComment(..) => panic!("unexpected doc comment"),
|
AttrKind::DocComment(..) => panic!("unexpected doc comment"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -286,21 +289,22 @@ impl Attribute {
|
||||||
/// Extracts the MetaItem from inside this Attribute.
|
/// Extracts the MetaItem from inside this Attribute.
|
||||||
pub fn meta(&self) -> Option<MetaItem> {
|
pub fn meta(&self) -> Option<MetaItem> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => item.meta(self.span),
|
AttrKind::Normal(ref normal) => normal.item.meta(self.span),
|
||||||
AttrKind::DocComment(..) => None,
|
AttrKind::DocComment(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn meta_kind(&self) -> Option<MetaItemKind> {
|
pub fn meta_kind(&self) -> Option<MetaItemKind> {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(ref item, _) => item.meta_kind(),
|
AttrKind::Normal(ref normal) => normal.item.meta_kind(),
|
||||||
AttrKind::DocComment(..) => None,
|
AttrKind::DocComment(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tokens(&self) -> AttrAnnotatedTokenStream {
|
pub fn tokens(&self) -> AttrAnnotatedTokenStream {
|
||||||
match self.kind {
|
match self.kind {
|
||||||
AttrKind::Normal(_, ref tokens) => tokens
|
AttrKind::Normal(ref normal) => normal
|
||||||
|
.tokens
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
|
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
|
||||||
.create_token_stream(),
|
.create_token_stream(),
|
||||||
|
@ -361,7 +365,12 @@ pub fn mk_attr_from_item(
|
||||||
style: AttrStyle,
|
style: AttrStyle,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> Attribute {
|
) -> Attribute {
|
||||||
Attribute { kind: AttrKind::Normal(item, tokens), id: mk_attr_id(), style, span }
|
Attribute {
|
||||||
|
kind: AttrKind::Normal(P(ast::NormalAttr { item, tokens })),
|
||||||
|
id: mk_attr_id(),
|
||||||
|
style,
|
||||||
|
span,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an inner attribute with the given value and span.
|
/// Returns an inner attribute with the given value and span.
|
||||||
|
|
|
@ -596,7 +596,9 @@ pub fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
|
||||||
pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
|
pub fn noop_visit_attribute<T: MutVisitor>(attr: &mut Attribute, vis: &mut T) {
|
||||||
let Attribute { kind, id: _, style: _, span } = attr;
|
let Attribute { kind, id: _, style: _, span } = attr;
|
||||||
match kind {
|
match kind {
|
||||||
AttrKind::Normal(AttrItem { path, args, tokens }, attr_tokens) => {
|
AttrKind::Normal(normal) => {
|
||||||
|
let NormalAttr { item: AttrItem { path, args, tokens }, tokens: attr_tokens } =
|
||||||
|
&mut **normal;
|
||||||
vis.visit_path(path);
|
vis.visit_path(path);
|
||||||
visit_mac_args(args, vis);
|
visit_mac_args(args, vis);
|
||||||
visit_lazy_tts(tokens, vis);
|
visit_lazy_tts(tokens, vis);
|
||||||
|
@ -659,8 +661,8 @@ pub fn visit_attr_annotated_tt<T: MutVisitor>(tt: &mut AttrAnnotatedTokenTree, v
|
||||||
AttrAnnotatedTokenTree::Attributes(data) => {
|
AttrAnnotatedTokenTree::Attributes(data) => {
|
||||||
for attr in &mut *data.attrs {
|
for attr in &mut *data.attrs {
|
||||||
match &mut attr.kind {
|
match &mut attr.kind {
|
||||||
AttrKind::Normal(_, attr_tokens) => {
|
AttrKind::Normal(normal) => {
|
||||||
visit_lazy_tts(attr_tokens, vis);
|
visit_lazy_tts(&mut normal.tokens, vis);
|
||||||
}
|
}
|
||||||
AttrKind::DocComment(..) => {
|
AttrKind::DocComment(..) => {
|
||||||
vis.visit_span(&mut attr.span);
|
vis.visit_span(&mut attr.span);
|
||||||
|
|
|
@ -929,7 +929,7 @@ pub fn walk_vis<'a, V: Visitor<'a>>(visitor: &mut V, vis: &'a Visibility) {
|
||||||
|
|
||||||
pub fn walk_attribute<'a, V: Visitor<'a>>(visitor: &mut V, attr: &'a Attribute) {
|
pub fn walk_attribute<'a, V: Visitor<'a>>(visitor: &mut V, attr: &'a Attribute) {
|
||||||
match attr.kind {
|
match attr.kind {
|
||||||
AttrKind::Normal(ref item, ref _tokens) => walk_mac_args(visitor, &item.args),
|
AttrKind::Normal(ref normal) => walk_mac_args(visitor, &normal.item.args),
|
||||||
AttrKind::DocComment(..) => {}
|
AttrKind::DocComment(..) => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate tracing;
|
extern crate tracing;
|
||||||
|
|
||||||
|
use rustc_ast::ptr::P;
|
||||||
use rustc_ast::visit;
|
use rustc_ast::visit;
|
||||||
use rustc_ast::{self as ast, *};
|
use rustc_ast::{self as ast, *};
|
||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
|
@ -873,14 +874,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
// the `HirId`s. We don't actually need HIR version of attributes anyway.
|
// the `HirId`s. We don't actually need HIR version of attributes anyway.
|
||||||
// Tokens are also not needed after macro expansion and parsing.
|
// Tokens are also not needed after macro expansion and parsing.
|
||||||
let kind = match attr.kind {
|
let kind = match attr.kind {
|
||||||
AttrKind::Normal(ref item, _) => AttrKind::Normal(
|
AttrKind::Normal(ref normal) => AttrKind::Normal(P(NormalAttr {
|
||||||
AttrItem {
|
item: AttrItem {
|
||||||
path: item.path.clone(),
|
path: normal.item.path.clone(),
|
||||||
args: self.lower_mac_args(&item.args),
|
args: self.lower_mac_args(&normal.item.args),
|
||||||
tokens: None,
|
tokens: None,
|
||||||
},
|
},
|
||||||
None,
|
tokens: None,
|
||||||
),
|
})),
|
||||||
AttrKind::DocComment(comment_kind, data) => AttrKind::DocComment(comment_kind, data),
|
AttrKind::DocComment(comment_kind, data) => AttrKind::DocComment(comment_kind, data),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -442,12 +442,12 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
|
||||||
}
|
}
|
||||||
self.maybe_print_comment(attr.span.lo());
|
self.maybe_print_comment(attr.span.lo());
|
||||||
match attr.kind {
|
match attr.kind {
|
||||||
ast::AttrKind::Normal(ref item, _) => {
|
ast::AttrKind::Normal(ref normal) => {
|
||||||
match attr.style {
|
match attr.style {
|
||||||
ast::AttrStyle::Inner => self.word("#!["),
|
ast::AttrStyle::Inner => self.word("#!["),
|
||||||
ast::AttrStyle::Outer => self.word("#["),
|
ast::AttrStyle::Outer => self.word("#["),
|
||||||
}
|
}
|
||||||
self.print_attr_item(&item, attr.span);
|
self.print_attr_item(&normal.item, attr.span);
|
||||||
self.word("]");
|
self.word("]");
|
||||||
}
|
}
|
||||||
ast::AttrKind::DocComment(comment_kind, data) => {
|
ast::AttrKind::DocComment(comment_kind, data) => {
|
||||||
|
|
|
@ -42,12 +42,12 @@ impl<'ctx> rustc_ast::HashStableContext for StableHashingContext<'ctx> {
|
||||||
debug_assert!(!attr.is_doc_comment());
|
debug_assert!(!attr.is_doc_comment());
|
||||||
|
|
||||||
let ast::Attribute { kind, id: _, style, span } = attr;
|
let ast::Attribute { kind, id: _, style, span } = attr;
|
||||||
if let ast::AttrKind::Normal(item, tokens) = kind {
|
if let ast::AttrKind::Normal(normal) = kind {
|
||||||
item.hash_stable(self, hasher);
|
normal.item.hash_stable(self, hasher);
|
||||||
style.hash_stable(self, hasher);
|
style.hash_stable(self, hasher);
|
||||||
span.hash_stable(self, hasher);
|
span.hash_stable(self, hasher);
|
||||||
assert_matches!(
|
assert_matches!(
|
||||||
tokens.as_ref(),
|
normal.tokens.as_ref(),
|
||||||
None,
|
None,
|
||||||
"Tokens should have been removed during lowering!"
|
"Tokens should have been removed during lowering!"
|
||||||
);
|
);
|
||||||
|
|
|
@ -4,58 +4,58 @@ PRE EXPANSION AST STATS
|
||||||
Name Accumulated Size Count Item Size
|
Name Accumulated Size Count Item Size
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
ExprField 48 ( 0.5%) 1 48
|
ExprField 48 ( 0.5%) 1 48
|
||||||
|
Attribute 64 ( 0.7%) 2 32
|
||||||
|
- Normal 32 ( 0.4%) 1
|
||||||
|
- DocComment 32 ( 0.4%) 1
|
||||||
GenericArgs 64 ( 0.7%) 1 64
|
GenericArgs 64 ( 0.7%) 1 64
|
||||||
- AngleBracketed 64 ( 0.7%) 1
|
- AngleBracketed 64 ( 0.7%) 1
|
||||||
Local 72 ( 0.8%) 1 72
|
Local 72 ( 0.8%) 1 72
|
||||||
WherePredicate 72 ( 0.8%) 1 72
|
WherePredicate 72 ( 0.8%) 1 72
|
||||||
- BoundPredicate 72 ( 0.8%) 1
|
- BoundPredicate 72 ( 0.8%) 1
|
||||||
Crate 72 ( 0.8%) 1 72
|
Crate 72 ( 0.8%) 1 72
|
||||||
Arm 96 ( 1.0%) 2 48
|
Arm 96 ( 1.1%) 2 48
|
||||||
FieldDef 160 ( 1.7%) 2 80
|
FieldDef 160 ( 1.8%) 2 80
|
||||||
ForeignItem 160 ( 1.7%) 1 160
|
ForeignItem 160 ( 1.8%) 1 160
|
||||||
- Fn 160 ( 1.7%) 1
|
- Fn 160 ( 1.8%) 1
|
||||||
Stmt 160 ( 1.7%) 5 32
|
Stmt 160 ( 1.8%) 5 32
|
||||||
- Local 32 ( 0.3%) 1
|
- Local 32 ( 0.4%) 1
|
||||||
- MacCall 32 ( 0.3%) 1
|
- MacCall 32 ( 0.4%) 1
|
||||||
- Expr 96 ( 1.0%) 3
|
- Expr 96 ( 1.1%) 3
|
||||||
Param 160 ( 1.7%) 4 40
|
Param 160 ( 1.8%) 4 40
|
||||||
FnDecl 200 ( 2.2%) 5 40
|
FnDecl 200 ( 2.2%) 5 40
|
||||||
Variant 240 ( 2.6%) 2 120
|
Variant 240 ( 2.7%) 2 120
|
||||||
Block 288 ( 3.1%) 6 48
|
Block 288 ( 3.2%) 6 48
|
||||||
Attribute 304 ( 3.3%) 2 152
|
GenericBound 352 ( 4.0%) 4 88
|
||||||
- Normal 152 ( 1.7%) 1
|
- Trait 352 ( 4.0%) 4
|
||||||
- DocComment 152 ( 1.7%) 1
|
GenericParam 520 ( 5.8%) 5 104
|
||||||
GenericBound 352 ( 3.8%) 4 88
|
AssocItem 640 ( 7.2%) 4 160
|
||||||
- Trait 352 ( 3.8%) 4
|
- TyAlias 320 ( 3.6%) 2
|
||||||
GenericParam 520 ( 5.7%) 5 104
|
- Fn 320 ( 3.6%) 2
|
||||||
AssocItem 640 ( 7.0%) 4 160
|
PathSegment 720 ( 8.1%) 30 24
|
||||||
- TyAlias 320 ( 3.5%) 2
|
Expr 832 ( 9.3%) 8 104
|
||||||
- Fn 320 ( 3.5%) 2
|
- Path 104 ( 1.2%) 1
|
||||||
PathSegment 720 ( 7.9%) 30 24
|
- Match 104 ( 1.2%) 1
|
||||||
Expr 832 ( 9.1%) 8 104
|
- Struct 104 ( 1.2%) 1
|
||||||
- Path 104 ( 1.1%) 1
|
|
||||||
- Match 104 ( 1.1%) 1
|
|
||||||
- Struct 104 ( 1.1%) 1
|
|
||||||
- Lit 208 ( 2.3%) 2
|
- Lit 208 ( 2.3%) 2
|
||||||
- Block 312 ( 3.4%) 3
|
- Block 312 ( 3.5%) 3
|
||||||
Pat 840 ( 9.2%) 7 120
|
Pat 840 ( 9.4%) 7 120
|
||||||
- Struct 120 ( 1.3%) 1
|
- Struct 120 ( 1.3%) 1
|
||||||
- Wild 120 ( 1.3%) 1
|
- Wild 120 ( 1.3%) 1
|
||||||
- Ident 600 ( 6.6%) 5
|
- Ident 600 ( 6.7%) 5
|
||||||
Ty 1_344 (14.7%) 14 96
|
Ty 1_344 (15.1%) 14 96
|
||||||
- Rptr 96 ( 1.0%) 1
|
- Rptr 96 ( 1.1%) 1
|
||||||
- Ptr 96 ( 1.0%) 1
|
- Ptr 96 ( 1.1%) 1
|
||||||
- ImplicitSelf 192 ( 2.1%) 2
|
- ImplicitSelf 192 ( 2.2%) 2
|
||||||
- Path 960 (10.5%) 10
|
- Path 960 (10.8%) 10
|
||||||
Item 1_800 (19.7%) 9 200
|
Item 1_800 (20.2%) 9 200
|
||||||
- Trait 200 ( 2.2%) 1
|
- Trait 200 ( 2.2%) 1
|
||||||
- Enum 200 ( 2.2%) 1
|
- Enum 200 ( 2.2%) 1
|
||||||
- ForeignMod 200 ( 2.2%) 1
|
- ForeignMod 200 ( 2.2%) 1
|
||||||
- Impl 200 ( 2.2%) 1
|
- Impl 200 ( 2.2%) 1
|
||||||
- Fn 400 ( 4.4%) 2
|
- Fn 400 ( 4.5%) 2
|
||||||
- Use 600 ( 6.6%) 3
|
- Use 600 ( 6.7%) 3
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
Total 9_144
|
Total 8_904
|
||||||
|
|
||||||
|
|
||||||
POST EXPANSION AST STATS
|
POST EXPANSION AST STATS
|
||||||
|
@ -63,61 +63,61 @@ POST EXPANSION AST STATS
|
||||||
Name Accumulated Size Count Item Size
|
Name Accumulated Size Count Item Size
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
ExprField 48 ( 0.5%) 1 48
|
ExprField 48 ( 0.5%) 1 48
|
||||||
GenericArgs 64 ( 0.6%) 1 64
|
GenericArgs 64 ( 0.7%) 1 64
|
||||||
- AngleBracketed 64 ( 0.6%) 1
|
- AngleBracketed 64 ( 0.7%) 1
|
||||||
Local 72 ( 0.7%) 1 72
|
Local 72 ( 0.7%) 1 72
|
||||||
WherePredicate 72 ( 0.7%) 1 72
|
WherePredicate 72 ( 0.7%) 1 72
|
||||||
- BoundPredicate 72 ( 0.7%) 1
|
- BoundPredicate 72 ( 0.7%) 1
|
||||||
Crate 72 ( 0.7%) 1 72
|
Crate 72 ( 0.7%) 1 72
|
||||||
Arm 96 ( 0.9%) 2 48
|
Arm 96 ( 1.0%) 2 48
|
||||||
InlineAsm 120 ( 1.2%) 1 120
|
InlineAsm 120 ( 1.2%) 1 120
|
||||||
FieldDef 160 ( 1.6%) 2 80
|
Attribute 128 ( 1.3%) 4 32
|
||||||
ForeignItem 160 ( 1.6%) 1 160
|
- DocComment 32 ( 0.3%) 1
|
||||||
- Fn 160 ( 1.6%) 1
|
- Normal 96 ( 1.0%) 3
|
||||||
Stmt 160 ( 1.6%) 5 32
|
FieldDef 160 ( 1.7%) 2 80
|
||||||
|
ForeignItem 160 ( 1.7%) 1 160
|
||||||
|
- Fn 160 ( 1.7%) 1
|
||||||
|
Stmt 160 ( 1.7%) 5 32
|
||||||
- Local 32 ( 0.3%) 1
|
- Local 32 ( 0.3%) 1
|
||||||
- Semi 32 ( 0.3%) 1
|
- Semi 32 ( 0.3%) 1
|
||||||
- Expr 96 ( 0.9%) 3
|
- Expr 96 ( 1.0%) 3
|
||||||
Param 160 ( 1.6%) 4 40
|
Param 160 ( 1.7%) 4 40
|
||||||
FnDecl 200 ( 2.0%) 5 40
|
FnDecl 200 ( 2.1%) 5 40
|
||||||
Variant 240 ( 2.4%) 2 120
|
Variant 240 ( 2.5%) 2 120
|
||||||
Block 288 ( 2.8%) 6 48
|
Block 288 ( 3.0%) 6 48
|
||||||
GenericBound 352 ( 3.5%) 4 88
|
GenericBound 352 ( 3.6%) 4 88
|
||||||
- Trait 352 ( 3.5%) 4
|
- Trait 352 ( 3.6%) 4
|
||||||
GenericParam 520 ( 5.1%) 5 104
|
GenericParam 520 ( 5.4%) 5 104
|
||||||
Attribute 608 ( 6.0%) 4 152
|
AssocItem 640 ( 6.6%) 4 160
|
||||||
- DocComment 152 ( 1.5%) 1
|
- TyAlias 320 ( 3.3%) 2
|
||||||
- Normal 456 ( 4.5%) 3
|
- Fn 320 ( 3.3%) 2
|
||||||
AssocItem 640 ( 6.3%) 4 160
|
PathSegment 792 ( 8.2%) 33 24
|
||||||
- TyAlias 320 ( 3.2%) 2
|
Pat 840 ( 8.7%) 7 120
|
||||||
- Fn 320 ( 3.2%) 2
|
|
||||||
PathSegment 792 ( 7.8%) 33 24
|
|
||||||
Pat 840 ( 8.3%) 7 120
|
|
||||||
- Struct 120 ( 1.2%) 1
|
- Struct 120 ( 1.2%) 1
|
||||||
- Wild 120 ( 1.2%) 1
|
- Wild 120 ( 1.2%) 1
|
||||||
- Ident 600 ( 5.9%) 5
|
- Ident 600 ( 6.2%) 5
|
||||||
Expr 936 ( 9.2%) 9 104
|
Expr 936 ( 9.7%) 9 104
|
||||||
- Path 104 ( 1.0%) 1
|
- Path 104 ( 1.1%) 1
|
||||||
- Match 104 ( 1.0%) 1
|
- Match 104 ( 1.1%) 1
|
||||||
- Struct 104 ( 1.0%) 1
|
- Struct 104 ( 1.1%) 1
|
||||||
- InlineAsm 104 ( 1.0%) 1
|
- InlineAsm 104 ( 1.1%) 1
|
||||||
- Lit 208 ( 2.1%) 2
|
- Lit 208 ( 2.2%) 2
|
||||||
- Block 312 ( 3.1%) 3
|
- Block 312 ( 3.2%) 3
|
||||||
Ty 1_344 (13.2%) 14 96
|
Ty 1_344 (13.9%) 14 96
|
||||||
- Rptr 96 ( 0.9%) 1
|
- Rptr 96 ( 1.0%) 1
|
||||||
- Ptr 96 ( 0.9%) 1
|
- Ptr 96 ( 1.0%) 1
|
||||||
- ImplicitSelf 192 ( 1.9%) 2
|
- ImplicitSelf 192 ( 2.0%) 2
|
||||||
- Path 960 ( 9.5%) 10
|
- Path 960 ( 9.9%) 10
|
||||||
Item 2_200 (21.7%) 11 200
|
Item 2_200 (22.8%) 11 200
|
||||||
- Trait 200 ( 2.0%) 1
|
- Trait 200 ( 2.1%) 1
|
||||||
- Enum 200 ( 2.0%) 1
|
- Enum 200 ( 2.1%) 1
|
||||||
- ExternCrate 200 ( 2.0%) 1
|
- ExternCrate 200 ( 2.1%) 1
|
||||||
- ForeignMod 200 ( 2.0%) 1
|
- ForeignMod 200 ( 2.1%) 1
|
||||||
- Impl 200 ( 2.0%) 1
|
- Impl 200 ( 2.1%) 1
|
||||||
- Fn 400 ( 3.9%) 2
|
- Fn 400 ( 4.1%) 2
|
||||||
- Use 800 ( 7.9%) 4
|
- Use 800 ( 8.3%) 4
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
Total 10_144
|
Total 9_664
|
||||||
|
|
||||||
|
|
||||||
HIR STATS
|
HIR STATS
|
||||||
|
@ -126,26 +126,26 @@ Name Accumulated Size Count Item Size
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
Param 64 ( 0.7%) 2 32
|
Param 64 ( 0.7%) 2 32
|
||||||
Local 64 ( 0.7%) 1 64
|
Local 64 ( 0.7%) 1 64
|
||||||
ForeignItem 72 ( 0.7%) 1 72
|
ForeignItem 72 ( 0.8%) 1 72
|
||||||
FieldDef 96 ( 1.0%) 2 48
|
FieldDef 96 ( 1.0%) 2 48
|
||||||
Arm 96 ( 1.0%) 2 48
|
Arm 96 ( 1.0%) 2 48
|
||||||
Stmt 96 ( 1.0%) 3 32
|
Stmt 96 ( 1.0%) 3 32
|
||||||
FnDecl 120 ( 1.2%) 3 40
|
FnDecl 120 ( 1.3%) 3 40
|
||||||
Lifetime 128 ( 1.3%) 4 32
|
Attribute 128 ( 1.4%) 4 32
|
||||||
Variant 160 ( 1.6%) 2 80
|
Lifetime 128 ( 1.4%) 4 32
|
||||||
ImplItem 176 ( 1.8%) 2 88
|
Variant 160 ( 1.7%) 2 80
|
||||||
GenericBound 192 ( 2.0%) 4 48
|
ImplItem 176 ( 1.9%) 2 88
|
||||||
TraitItem 192 ( 2.0%) 2 96
|
GenericBound 192 ( 2.1%) 4 48
|
||||||
WherePredicate 216 ( 2.2%) 3 72
|
TraitItem 192 ( 2.1%) 2 96
|
||||||
Block 288 ( 3.0%) 6 48
|
WherePredicate 216 ( 2.3%) 3 72
|
||||||
QPath 408 ( 4.2%) 17 24
|
Block 288 ( 3.1%) 6 48
|
||||||
Pat 440 ( 4.5%) 5 88
|
QPath 408 ( 4.4%) 17 24
|
||||||
Attribute 608 ( 6.2%) 4 152
|
Pat 440 ( 4.8%) 5 88
|
||||||
Expr 672 ( 6.9%) 12 56
|
Expr 672 ( 7.3%) 12 56
|
||||||
Item 960 ( 9.9%) 12 80
|
Item 960 (10.4%) 12 80
|
||||||
Ty 1_152 (11.8%) 16 72
|
Ty 1_152 (12.4%) 16 72
|
||||||
Path 1_296 (13.3%) 27 48
|
Path 1_296 (14.0%) 27 48
|
||||||
PathSegment 2_240 (23.0%) 40 56
|
PathSegment 2_240 (24.2%) 40 56
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
Total 9_736
|
Total 9_256
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@ impl EarlyLintPass for CrateInMacroDef {
|
||||||
|
|
||||||
fn is_macro_export(attr: &Attribute) -> bool {
|
fn is_macro_export(attr: &Attribute) -> bool {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let AttrKind::Normal(attr_item, _) = &attr.kind;
|
if let AttrKind::Normal(normal) = &attr.kind;
|
||||||
if let [segment] = attr_item.path.segments.as_slice();
|
if let [segment] = normal.item.path.segments.as_slice();
|
||||||
then {
|
then {
|
||||||
segment.ident.name == sym::macro_export
|
segment.ident.name == sym::macro_export
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -695,7 +695,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool {
|
||||||
l.style == r.style
|
l.style == r.style
|
||||||
&& match (&l.kind, &r.kind) {
|
&& match (&l.kind, &r.kind) {
|
||||||
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
|
(DocComment(l1, l2), DocComment(r1, r2)) => l1 == r1 && l2 == r2,
|
||||||
(Normal(l, _), Normal(r, _)) => eq_path(&l.path, &r.path) && eq_mac_args(&l.args, &r.args),
|
(Normal(l), Normal(r)) => eq_path(&l.item.path, &r.item.path) && eq_mac_args(&l.item.args, &r.item.args),
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ pub fn get_attr<'a>(
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
) -> impl Iterator<Item = &'a ast::Attribute> {
|
) -> impl Iterator<Item = &'a ast::Attribute> {
|
||||||
attrs.iter().filter(move |attr| {
|
attrs.iter().filter(move |attr| {
|
||||||
let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
|
let attr = if let ast::AttrKind::Normal(ref normal) = attr.kind {
|
||||||
attr
|
&normal.item
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1893,8 +1893,8 @@ pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> {
|
||||||
|
|
||||||
pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
|
pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
|
||||||
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
||||||
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
|
if let ast::AttrKind::Normal(ref normal) = attr.kind {
|
||||||
attr.path == sym::no_std
|
normal.item.path == sym::no_std
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -1903,8 +1903,8 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool {
|
||||||
|
|
||||||
pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
|
pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
|
||||||
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| {
|
||||||
if let ast::AttrKind::Normal(ref attr, _) = attr.kind {
|
if let ast::AttrKind::Normal(ref normal) = attr.kind {
|
||||||
attr.path == sym::no_core
|
normal.item.path == sym::no_core
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ fn get_skip_names(kind: &str, attrs: &[ast::Attribute]) -> Vec<String> {
|
||||||
for attr in attrs {
|
for attr in attrs {
|
||||||
// rustc_ast::ast::Path is implemented partialEq
|
// rustc_ast::ast::Path is implemented partialEq
|
||||||
// but it is designed for segments.len() == 1
|
// but it is designed for segments.len() == 1
|
||||||
if let ast::AttrKind::Normal(attr_item, _) = &attr.kind {
|
if let ast::AttrKind::Normal(normal) = &attr.kind {
|
||||||
if pprust::path_to_string(&attr_item.path) != path {
|
if pprust::path_to_string(&normal.item.path) != path {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -811,8 +811,8 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
match &attr.kind {
|
match &attr.kind {
|
||||||
ast::AttrKind::Normal(ref attribute_item, _)
|
ast::AttrKind::Normal(ref normal)
|
||||||
if self.is_unknown_rustfmt_attr(&attribute_item.path.segments) =>
|
if self.is_unknown_rustfmt_attr(&normal.item.path.segments) =>
|
||||||
{
|
{
|
||||||
let file_name = self.parse_sess.span_to_filename(attr.span);
|
let file_name = self.parse_sess.span_to_filename(attr.span);
|
||||||
self.report.append(
|
self.report.append(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue