diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 4 | ||||
| -rw-r--r-- | src/test/ui-fulldeps/pprust-expr-roundtrip.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/stats/hir-stats.stderr | 134 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/attr.rs | 5 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/imports.rs | 4 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/modules.rs | 8 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/parse/parser.rs | 2 |
7 files changed, 79 insertions, 83 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 51976a91cea..4c39021903c 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1130,7 +1130,7 @@ pub struct RenderedLink { #[derive(Clone, Debug, Default)] pub(crate) struct Attributes { pub(crate) doc_strings: Vec<DocFragment>, - pub(crate) other_attrs: Vec<ast::Attribute>, + pub(crate) other_attrs: ast::AttrVec, } impl Attributes { @@ -1173,7 +1173,7 @@ impl Attributes { doc_only: bool, ) -> Attributes { let mut doc_strings = Vec::new(); - let mut other_attrs = Vec::new(); + let mut other_attrs = ast::AttrVec::new(); for (attr, parent_module) in attrs { if let Some((doc_str, comment_kind)) = attr.doc_str_and_comment_kind() { trace!("got doc_str={doc_str:?}"); diff --git a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs index 0d9c9350efc..117b798710c 100644 --- a/src/test/ui-fulldeps/pprust-expr-roundtrip.rs +++ b/src/test/ui-fulldeps/pprust-expr-roundtrip.rs @@ -30,7 +30,6 @@ use rustc_ast::mut_visit::{self, visit_clobber, MutVisitor}; use rustc_ast::ptr::P; use rustc_ast::*; use rustc_ast_pretty::pprust; -use rustc_data_structures::thin_vec::ThinVec; use rustc_parse::new_parser_from_source_str; use rustc_session::parse::ParseSess; use rustc_span::source_map::FilePathMapping; @@ -47,7 +46,7 @@ fn parse_expr(ps: &ParseSess, src: &str) -> Option<P<Expr>> { // Helper functions for building exprs fn expr(kind: ExprKind) -> P<Expr> { - P(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: ThinVec::new(), tokens: None }) + P(Expr { id: DUMMY_NODE_ID, kind, span: DUMMY_SP, attrs: AttrVec::new(), tokens: None }) } fn make_x() -> P<Expr> { @@ -196,7 +195,7 @@ impl MutVisitor for AddParens { id: DUMMY_NODE_ID, kind: ExprKind::Paren(e), span: DUMMY_SP, - attrs: ThinVec::new(), + attrs: AttrVec::new(), tokens: None, }) }); diff --git a/src/test/ui/stats/hir-stats.stderr b/src/test/ui/stats/hir-stats.stderr index 61cb7b25e49..eb828bb9a2c 100644 --- a/src/test/ui/stats/hir-stats.stderr +++ b/src/test/ui/stats/hir-stats.stderr @@ -4,58 +4,58 @@ PRE EXPANSION AST STATS Name Accumulated Size Count Item Size ---------------------------------------------------------------- ExprField 48 ( 0.6%) 1 48 -Attribute 64 ( 0.7%) 2 32 +Crate 56 ( 0.7%) 1 56 +Attribute 64 ( 0.8%) 2 32 - Normal 32 ( 0.4%) 1 - DocComment 32 ( 0.4%) 1 -GenericArgs 64 ( 0.7%) 1 64 -- AngleBracketed 64 ( 0.7%) 1 -Local 72 ( 0.8%) 1 72 -WherePredicate 72 ( 0.8%) 1 72 -- BoundPredicate 72 ( 0.8%) 1 -Crate 72 ( 0.8%) 1 72 +GenericArgs 64 ( 0.8%) 1 64 +- AngleBracketed 64 ( 0.8%) 1 +Local 72 ( 0.9%) 1 72 +WherePredicate 72 ( 0.9%) 1 72 +- BoundPredicate 72 ( 0.9%) 1 Arm 96 ( 1.1%) 2 48 -ForeignItem 112 ( 1.3%) 1 112 -- Fn 112 ( 1.3%) 1 -FieldDef 160 ( 1.8%) 2 80 -Stmt 160 ( 1.8%) 5 32 +ForeignItem 96 ( 1.1%) 1 96 +- Fn 96 ( 1.1%) 1 +FieldDef 160 ( 1.9%) 2 80 +Stmt 160 ( 1.9%) 5 32 - Local 32 ( 0.4%) 1 - MacCall 32 ( 0.4%) 1 - Expr 96 ( 1.1%) 3 -Param 160 ( 1.8%) 4 40 -FnDecl 200 ( 2.3%) 5 40 +Param 160 ( 1.9%) 4 40 +FnDecl 200 ( 2.4%) 5 40 Variant 240 ( 2.8%) 2 120 -Block 288 ( 3.3%) 6 48 -GenericBound 352 ( 4.0%) 4 88 -- Trait 352 ( 4.0%) 4 -AssocItem 480 ( 5.5%) 4 120 -- TyAlias 240 ( 2.8%) 2 -- Fn 240 ( 2.8%) 2 -GenericParam 520 ( 6.0%) 5 104 -PathSegment 720 ( 8.3%) 30 24 -Expr 832 ( 9.6%) 8 104 +Block 288 ( 3.4%) 6 48 +GenericBound 352 ( 4.2%) 4 88 +- Trait 352 ( 4.2%) 4 +AssocItem 416 ( 4.9%) 4 104 +- TyAlias 208 ( 2.5%) 2 +- Fn 208 ( 2.5%) 2 +GenericParam 520 ( 6.1%) 5 104 +PathSegment 720 ( 8.5%) 30 24 +Expr 832 ( 9.8%) 8 104 - Path 104 ( 1.2%) 1 - Match 104 ( 1.2%) 1 - Struct 104 ( 1.2%) 1 -- Lit 208 ( 2.4%) 2 -- Block 312 ( 3.6%) 3 -Pat 840 ( 9.7%) 7 120 +- Lit 208 ( 2.5%) 2 +- Block 312 ( 3.7%) 3 +Pat 840 ( 9.9%) 7 120 - Struct 120 ( 1.4%) 1 - Wild 120 ( 1.4%) 1 -- Ident 600 ( 6.9%) 5 -Ty 1_344 (15.5%) 14 96 +- Ident 600 ( 7.1%) 5 +Ty 1_344 (15.9%) 14 96 - Rptr 96 ( 1.1%) 1 - Ptr 96 ( 1.1%) 1 -- ImplicitSelf 192 ( 2.2%) 2 -- Path 960 (11.0%) 10 -Item 1_800 (20.7%) 9 200 -- Trait 200 ( 2.3%) 1 -- Enum 200 ( 2.3%) 1 -- ForeignMod 200 ( 2.3%) 1 -- Impl 200 ( 2.3%) 1 -- Fn 400 ( 4.6%) 2 -- Use 600 ( 6.9%) 3 +- ImplicitSelf 192 ( 2.3%) 2 +- Path 960 (11.4%) 10 +Item 1_656 (19.6%) 9 184 +- Trait 184 ( 2.2%) 1 +- Enum 184 ( 2.2%) 1 +- ForeignMod 184 ( 2.2%) 1 +- Impl 184 ( 2.2%) 1 +- Fn 368 ( 4.4%) 2 +- Use 552 ( 6.5%) 3 ---------------------------------------------------------------- -Total 8_696 +Total 8_456 POST EXPANSION AST STATS @@ -63,15 +63,15 @@ POST EXPANSION AST STATS Name Accumulated Size Count Item Size ---------------------------------------------------------------- ExprField 48 ( 0.5%) 1 48 +Crate 56 ( 0.6%) 1 56 GenericArgs 64 ( 0.7%) 1 64 - AngleBracketed 64 ( 0.7%) 1 Local 72 ( 0.8%) 1 72 WherePredicate 72 ( 0.8%) 1 72 - BoundPredicate 72 ( 0.8%) 1 -Crate 72 ( 0.8%) 1 72 Arm 96 ( 1.0%) 2 48 -ForeignItem 112 ( 1.2%) 1 112 -- Fn 112 ( 1.2%) 1 +ForeignItem 96 ( 1.0%) 1 96 +- Fn 96 ( 1.0%) 1 InlineAsm 120 ( 1.3%) 1 120 Attribute 128 ( 1.4%) 4 32 - DocComment 32 ( 0.3%) 1 @@ -82,42 +82,42 @@ Stmt 160 ( 1.7%) 5 32 - Semi 32 ( 0.3%) 1 - Expr 96 ( 1.0%) 3 Param 160 ( 1.7%) 4 40 -FnDecl 200 ( 2.1%) 5 40 -Variant 240 ( 2.5%) 2 120 -Block 288 ( 3.0%) 6 48 -GenericBound 352 ( 3.7%) 4 88 -- Trait 352 ( 3.7%) 4 -AssocItem 480 ( 5.1%) 4 120 -- TyAlias 240 ( 2.5%) 2 -- Fn 240 ( 2.5%) 2 -GenericParam 520 ( 5.5%) 5 104 -PathSegment 792 ( 8.4%) 33 24 -Pat 840 ( 8.9%) 7 120 +FnDecl 200 ( 2.2%) 5 40 +Variant 240 ( 2.6%) 2 120 +Block 288 ( 3.1%) 6 48 +GenericBound 352 ( 3.8%) 4 88 +- Trait 352 ( 3.8%) 4 +AssocItem 416 ( 4.5%) 4 104 +- TyAlias 208 ( 2.3%) 2 +- Fn 208 ( 2.3%) 2 +GenericParam 520 ( 5.7%) 5 104 +PathSegment 792 ( 8.6%) 33 24 +Pat 840 ( 9.1%) 7 120 - Struct 120 ( 1.3%) 1 - Wild 120 ( 1.3%) 1 -- Ident 600 ( 6.3%) 5 -Expr 936 ( 9.9%) 9 104 +- Ident 600 ( 6.5%) 5 +Expr 936 (10.2%) 9 104 - Path 104 ( 1.1%) 1 - Match 104 ( 1.1%) 1 - Struct 104 ( 1.1%) 1 - InlineAsm 104 ( 1.1%) 1 -- Lit 208 ( 2.2%) 2 -- Block 312 ( 3.3%) 3 -Ty 1_344 (14.2%) 14 96 +- Lit 208 ( 2.3%) 2 +- Block 312 ( 3.4%) 3 +Ty 1_344 (14.6%) 14 96 - Rptr 96 ( 1.0%) 1 - Ptr 96 ( 1.0%) 1 -- ImplicitSelf 192 ( 2.0%) 2 -- Path 960 (10.2%) 10 -Item 2_200 (23.3%) 11 200 -- Trait 200 ( 2.1%) 1 -- Enum 200 ( 2.1%) 1 -- ExternCrate 200 ( 2.1%) 1 -- ForeignMod 200 ( 2.1%) 1 -- Impl 200 ( 2.1%) 1 -- Fn 400 ( 4.2%) 2 -- Use 800 ( 8.5%) 4 +- ImplicitSelf 192 ( 2.1%) 2 +- Path 960 (10.5%) 10 +Item 2_024 (22.0%) 11 184 +- Trait 184 ( 2.0%) 1 +- Enum 184 ( 2.0%) 1 +- ExternCrate 184 ( 2.0%) 1 +- ForeignMod 184 ( 2.0%) 1 +- Impl 184 ( 2.0%) 1 +- Fn 368 ( 4.0%) 2 +- Use 736 ( 8.0%) 4 ---------------------------------------------------------------- -Total 9_456 +Total 9_184 HIR STATS diff --git a/src/tools/rustfmt/src/attr.rs b/src/tools/rustfmt/src/attr.rs index 41ba9a847e6..f5c1ee5fdd1 100644 --- a/src/tools/rustfmt/src/attr.rs +++ b/src/tools/rustfmt/src/attr.rs @@ -49,10 +49,7 @@ pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span { } /// Returns attributes that are within `outer_span`. -pub(crate) fn filter_inline_attrs( - attrs: &[ast::Attribute], - outer_span: Span, -) -> Vec<ast::Attribute> { +pub(crate) fn filter_inline_attrs(attrs: &[ast::Attribute], outer_span: Span) -> ast::AttrVec { attrs .iter() .filter(|a| outer_span.lo() <= a.span.lo() && a.span.hi() <= outer_span.hi()) diff --git a/src/tools/rustfmt/src/imports.rs b/src/tools/rustfmt/src/imports.rs index 8d41c881589..b6530c69243 100644 --- a/src/tools/rustfmt/src/imports.rs +++ b/src/tools/rustfmt/src/imports.rs @@ -116,7 +116,7 @@ pub(crate) struct UseTree { // Additional fields for top level use items. // Should we have another struct for top-level use items rather than reusing this? visibility: Option<ast::Visibility>, - attrs: Option<Vec<ast::Attribute>>, + attrs: Option<ast::AttrVec>, } impl PartialEq for UseTree { @@ -417,7 +417,7 @@ impl UseTree { list_item: Option<ListItem>, visibility: Option<ast::Visibility>, opt_lo: Option<BytePos>, - attrs: Option<Vec<ast::Attribute>>, + attrs: Option<ast::AttrVec>, ) -> UseTree { let span = if let Some(lo) = opt_lo { mk_sp(lo, a.span.hi()) diff --git a/src/tools/rustfmt/src/modules.rs b/src/tools/rustfmt/src/modules.rs index 81da724329f..7a0d1736c59 100644 --- a/src/tools/rustfmt/src/modules.rs +++ b/src/tools/rustfmt/src/modules.rs @@ -26,7 +26,7 @@ type FileModMap<'ast> = BTreeMap<FileName, Module<'ast>>; pub(crate) struct Module<'a> { ast_mod_kind: Option<Cow<'a, ast::ModKind>>, pub(crate) items: Cow<'a, Vec<rustc_ast::ptr::P<ast::Item>>>, - inner_attr: Vec<ast::Attribute>, + inner_attr: ast::AttrVec, pub(crate) span: Span, } @@ -35,7 +35,7 @@ impl<'a> Module<'a> { mod_span: Span, ast_mod_kind: Option<Cow<'a, ast::ModKind>>, mod_items: Cow<'a, Vec<rustc_ast::ptr::P<ast::Item>>>, - mod_attrs: Cow<'a, Vec<ast::Attribute>>, + mod_attrs: Cow<'a, ast::AttrVec>, ) -> Self { let inner_attr = mod_attrs .iter() @@ -158,7 +158,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { module_item.item.span, Some(Cow::Owned(sub_mod_kind.clone())), Cow::Owned(vec![]), - Cow::Owned(vec![]), + Cow::Owned(ast::AttrVec::new()), ), )?; } @@ -185,7 +185,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> { span, Some(Cow::Owned(sub_mod_kind.clone())), Cow::Owned(vec![]), - Cow::Owned(vec![]), + Cow::Owned(ast::AttrVec::new()), ), )?; } diff --git a/src/tools/rustfmt/src/parse/parser.rs b/src/tools/rustfmt/src/parse/parser.rs index 268c72649a6..e0bd065518b 100644 --- a/src/tools/rustfmt/src/parse/parser.rs +++ b/src/tools/rustfmt/src/parse/parser.rs @@ -109,7 +109,7 @@ impl<'a> Parser<'a> { sess: &'a ParseSess, path: &Path, span: Span, - ) -> Result<(Vec<ast::Attribute>, Vec<ptr::P<ast::Item>>, Span), ParserError> { + ) -> Result<(ast::AttrVec, Vec<ptr::P<ast::Item>>, Span), ParserError> { let result = catch_unwind(AssertUnwindSafe(|| { let mut parser = new_parser_from_file(sess.inner(), path, Some(span)); match parser.parse_mod(&TokenKind::Eof) { |
