diff options
| author | bors <bors@rust-lang.org> | 2022-08-16 07:54:22 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-16 07:54:22 +0000 |
| commit | 14a459bf37bc19476d43e0045d078121c12d3fef (patch) | |
| tree | 36e797a07bf83ddd338f6bb369f3ea09d4a384ea /src | |
| parent | 8556e6620e4866526b3cea767ad8c20ae877a569 (diff) | |
| parent | 85a6cd6a47ea0f7129dff5038fce7398ceb18222 (diff) | |
| download | rust-14a459bf37bc19476d43e0045d078121c12d3fef.tar.gz rust-14a459bf37bc19476d43e0045d078121c12d3fef.zip | |
Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkov
Shrink `ast::Attribute`. r? `@ghost`
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/stats/hir-stats.stderr | 200 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs | 4 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/ast_utils.rs | 2 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/attrs.rs | 4 | ||||
| -rw-r--r-- | src/tools/clippy/clippy_utils/src/lib.rs | 8 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/skip.rs | 4 | ||||
| -rw-r--r-- | src/tools/rustfmt/src/visitor.rs | 4 |
7 files changed, 113 insertions, 113 deletions
diff --git a/src/test/ui/stats/hir-stats.stderr b/src/test/ui/stats/hir-stats.stderr index f4874408c90..9ea32e8d64e 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.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 - 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 -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 -- MacCall 32 ( 0.3%) 1 -- Expr 96 ( 1.0%) 3 -Param 160 ( 1.7%) 4 40 +Arm 96 ( 1.1%) 2 48 +FieldDef 160 ( 1.8%) 2 80 +ForeignItem 160 ( 1.8%) 1 160 +- Fn 160 ( 1.8%) 1 +Stmt 160 ( 1.8%) 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.2%) 5 40 -Variant 240 ( 2.6%) 2 120 -Block 288 ( 3.1%) 6 48 -Attribute 304 ( 3.3%) 2 152 -- Normal 152 ( 1.7%) 1 -- DocComment 152 ( 1.7%) 1 -GenericBound 352 ( 3.8%) 4 88 -- Trait 352 ( 3.8%) 4 -GenericParam 520 ( 5.7%) 5 104 -AssocItem 640 ( 7.0%) 4 160 -- TyAlias 320 ( 3.5%) 2 -- Fn 320 ( 3.5%) 2 -PathSegment 720 ( 7.9%) 30 24 -Expr 832 ( 9.1%) 8 104 -- Path 104 ( 1.1%) 1 -- Match 104 ( 1.1%) 1 -- Struct 104 ( 1.1%) 1 +Variant 240 ( 2.7%) 2 120 +Block 288 ( 3.2%) 6 48 +GenericBound 352 ( 4.0%) 4 88 +- Trait 352 ( 4.0%) 4 +GenericParam 520 ( 5.8%) 5 104 +AssocItem 640 ( 7.2%) 4 160 +- TyAlias 320 ( 3.6%) 2 +- Fn 320 ( 3.6%) 2 +PathSegment 720 ( 8.1%) 30 24 +Expr 832 ( 9.3%) 8 104 +- Path 104 ( 1.2%) 1 +- Match 104 ( 1.2%) 1 +- Struct 104 ( 1.2%) 1 - Lit 208 ( 2.3%) 2 -- Block 312 ( 3.4%) 3 -Pat 840 ( 9.2%) 7 120 +- Block 312 ( 3.5%) 3 +Pat 840 ( 9.4%) 7 120 - Struct 120 ( 1.3%) 1 - Wild 120 ( 1.3%) 1 -- Ident 600 ( 6.6%) 5 -Ty 1_344 (14.7%) 14 96 -- Rptr 96 ( 1.0%) 1 -- Ptr 96 ( 1.0%) 1 -- ImplicitSelf 192 ( 2.1%) 2 -- Path 960 (10.5%) 10 -Item 1_800 (19.7%) 9 200 +- Ident 600 ( 6.7%) 5 +Ty 1_344 (15.1%) 14 96 +- Rptr 96 ( 1.1%) 1 +- Ptr 96 ( 1.1%) 1 +- ImplicitSelf 192 ( 2.2%) 2 +- Path 960 (10.8%) 10 +Item 1_800 (20.2%) 9 200 - Trait 200 ( 2.2%) 1 - Enum 200 ( 2.2%) 1 - ForeignMod 200 ( 2.2%) 1 - Impl 200 ( 2.2%) 1 -- Fn 400 ( 4.4%) 2 -- Use 600 ( 6.6%) 3 +- Fn 400 ( 4.5%) 2 +- Use 600 ( 6.7%) 3 ---------------------------------------------------------------- -Total 9_144 +Total 8_904 POST EXPANSION AST STATS @@ -63,61 +63,61 @@ POST EXPANSION AST STATS Name Accumulated Size Count Item Size ---------------------------------------------------------------- ExprField 48 ( 0.5%) 1 48 -GenericArgs 64 ( 0.6%) 1 64 -- AngleBracketed 64 ( 0.6%) 1 +GenericArgs 64 ( 0.7%) 1 64 +- AngleBracketed 64 ( 0.7%) 1 Local 72 ( 0.7%) 1 72 WherePredicate 72 ( 0.7%) 1 72 - BoundPredicate 72 ( 0.7%) 1 Crate 72 ( 0.7%) 1 72 -Arm 96 ( 0.9%) 2 48 +Arm 96 ( 1.0%) 2 48 InlineAsm 120 ( 1.2%) 1 120 -FieldDef 160 ( 1.6%) 2 80 -ForeignItem 160 ( 1.6%) 1 160 -- Fn 160 ( 1.6%) 1 -Stmt 160 ( 1.6%) 5 32 +Attribute 128 ( 1.3%) 4 32 +- DocComment 32 ( 0.3%) 1 +- Normal 96 ( 1.0%) 3 +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 - Semi 32 ( 0.3%) 1 -- Expr 96 ( 0.9%) 3 -Param 160 ( 1.6%) 4 40 -FnDecl 200 ( 2.0%) 5 40 -Variant 240 ( 2.4%) 2 120 -Block 288 ( 2.8%) 6 48 -GenericBound 352 ( 3.5%) 4 88 -- Trait 352 ( 3.5%) 4 -GenericParam 520 ( 5.1%) 5 104 -Attribute 608 ( 6.0%) 4 152 -- DocComment 152 ( 1.5%) 1 -- Normal 456 ( 4.5%) 3 -AssocItem 640 ( 6.3%) 4 160 -- TyAlias 320 ( 3.2%) 2 -- Fn 320 ( 3.2%) 2 -PathSegment 792 ( 7.8%) 33 24 -Pat 840 ( 8.3%) 7 120 +- 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.6%) 4 88 +- Trait 352 ( 3.6%) 4 +GenericParam 520 ( 5.4%) 5 104 +AssocItem 640 ( 6.6%) 4 160 +- TyAlias 320 ( 3.3%) 2 +- Fn 320 ( 3.3%) 2 +PathSegment 792 ( 8.2%) 33 24 +Pat 840 ( 8.7%) 7 120 - Struct 120 ( 1.2%) 1 - Wild 120 ( 1.2%) 1 -- Ident 600 ( 5.9%) 5 -Expr 936 ( 9.2%) 9 104 -- Path 104 ( 1.0%) 1 -- Match 104 ( 1.0%) 1 -- Struct 104 ( 1.0%) 1 -- InlineAsm 104 ( 1.0%) 1 -- Lit 208 ( 2.1%) 2 -- Block 312 ( 3.1%) 3 -Ty 1_344 (13.2%) 14 96 -- Rptr 96 ( 0.9%) 1 -- Ptr 96 ( 0.9%) 1 -- ImplicitSelf 192 ( 1.9%) 2 -- Path 960 ( 9.5%) 10 -Item 2_200 (21.7%) 11 200 -- Trait 200 ( 2.0%) 1 -- Enum 200 ( 2.0%) 1 -- ExternCrate 200 ( 2.0%) 1 -- ForeignMod 200 ( 2.0%) 1 -- Impl 200 ( 2.0%) 1 -- Fn 400 ( 3.9%) 2 -- Use 800 ( 7.9%) 4 +- Ident 600 ( 6.2%) 5 +Expr 936 ( 9.7%) 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.2%) 3 +Ty 1_344 (13.9%) 14 96 +- Rptr 96 ( 1.0%) 1 +- Ptr 96 ( 1.0%) 1 +- ImplicitSelf 192 ( 2.0%) 2 +- Path 960 ( 9.9%) 10 +Item 2_200 (22.8%) 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.1%) 2 +- Use 800 ( 8.3%) 4 ---------------------------------------------------------------- -Total 10_144 +Total 9_664 HIR STATS @@ -126,26 +126,26 @@ Name Accumulated Size Count Item Size ---------------------------------------------------------------- Param 64 ( 0.7%) 2 32 Local 64 ( 0.7%) 1 64 -ForeignItem 72 ( 0.7%) 1 72 +ForeignItem 72 ( 0.8%) 1 72 FieldDef 96 ( 1.0%) 2 48 Arm 96 ( 1.0%) 2 48 Stmt 96 ( 1.0%) 3 32 -FnDecl 120 ( 1.2%) 3 40 -Lifetime 128 ( 1.3%) 4 32 -Variant 160 ( 1.6%) 2 80 -ImplItem 176 ( 1.8%) 2 88 -GenericBound 192 ( 2.0%) 4 48 -TraitItem 192 ( 2.0%) 2 96 -WherePredicate 216 ( 2.2%) 3 72 -Block 288 ( 3.0%) 6 48 -QPath 408 ( 4.2%) 17 24 -Pat 440 ( 4.5%) 5 88 -Attribute 608 ( 6.2%) 4 152 -Expr 672 ( 6.9%) 12 56 -Item 960 ( 9.9%) 12 80 -Ty 1_152 (11.8%) 16 72 -Path 1_296 (13.3%) 27 48 -PathSegment 2_240 (23.0%) 40 56 +FnDecl 120 ( 1.3%) 3 40 +Attribute 128 ( 1.4%) 4 32 +Lifetime 128 ( 1.4%) 4 32 +Variant 160 ( 1.7%) 2 80 +ImplItem 176 ( 1.9%) 2 88 +GenericBound 192 ( 2.1%) 4 48 +TraitItem 192 ( 2.1%) 2 96 +WherePredicate 216 ( 2.3%) 3 72 +Block 288 ( 3.1%) 6 48 +QPath 408 ( 4.4%) 17 24 +Pat 440 ( 4.8%) 5 88 +Expr 672 ( 7.3%) 12 56 +Item 960 (10.4%) 12 80 +Ty 1_152 (12.4%) 16 72 +Path 1_296 (14.0%) 27 48 +PathSegment 2_240 (24.2%) 40 56 ---------------------------------------------------------------- -Total 9_736 +Total 9_256 diff --git a/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs b/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs index 454ec23388a..20cc330e035 100644 --- a/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs +++ b/src/tools/clippy/clippy_lints/src/crate_in_macro_def.rs @@ -74,8 +74,8 @@ impl EarlyLintPass for CrateInMacroDef { fn is_macro_export(attr: &Attribute) -> bool { if_chain! { - if let AttrKind::Normal(attr_item, _) = &attr.kind; - if let [segment] = attr_item.path.segments.as_slice(); + if let AttrKind::Normal(normal) = &attr.kind; + if let [segment] = normal.item.path.segments.as_slice(); then { segment.ident.name == sym::macro_export } else { diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs index 9f74729bdfa..493991f30e8 100644 --- a/src/tools/clippy/clippy_utils/src/ast_utils.rs +++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs @@ -695,7 +695,7 @@ pub fn eq_attr(l: &Attribute, r: &Attribute) -> bool { l.style == r.style && match (&l.kind, &r.kind) { (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, } } diff --git a/src/tools/clippy/clippy_utils/src/attrs.rs b/src/tools/clippy/clippy_utils/src/attrs.rs index 186bba09d20..8ab77c88166 100644 --- a/src/tools/clippy/clippy_utils/src/attrs.rs +++ b/src/tools/clippy/clippy_utils/src/attrs.rs @@ -59,8 +59,8 @@ pub fn get_attr<'a>( name: &'static str, ) -> impl Iterator<Item = &'a ast::Attribute> { attrs.iter().filter(move |attr| { - let attr = if let ast::AttrKind::Normal(ref attr, _) = attr.kind { - attr + let attr = if let ast::AttrKind::Normal(ref normal) = attr.kind { + &normal.item } else { return false; }; diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index dc772e5efee..f716f009ff3 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -1893,8 +1893,8 @@ pub fn std_or_core(cx: &LateContext<'_>) -> Option<&'static str> { pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool { cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| { - if let ast::AttrKind::Normal(ref attr, _) = attr.kind { - attr.path == sym::no_std + if let ast::AttrKind::Normal(ref normal) = attr.kind { + normal.item.path == sym::no_std } else { false } @@ -1903,8 +1903,8 @@ pub fn is_no_std_crate(cx: &LateContext<'_>) -> bool { pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool { cx.tcx.hir().attrs(hir::CRATE_HIR_ID).iter().any(|attr| { - if let ast::AttrKind::Normal(ref attr, _) = attr.kind { - attr.path == sym::no_core + if let ast::AttrKind::Normal(ref normal) = attr.kind { + normal.item.path == sym::no_core } else { false } diff --git a/src/tools/rustfmt/src/skip.rs b/src/tools/rustfmt/src/skip.rs index 0fdc097efc2..032922d421d 100644 --- a/src/tools/rustfmt/src/skip.rs +++ b/src/tools/rustfmt/src/skip.rs @@ -58,8 +58,8 @@ fn get_skip_names(kind: &str, attrs: &[ast::Attribute]) -> Vec<String> { for attr in attrs { // rustc_ast::ast::Path is implemented partialEq // but it is designed for segments.len() == 1 - if let ast::AttrKind::Normal(attr_item, _) = &attr.kind { - if pprust::path_to_string(&attr_item.path) != path { + if let ast::AttrKind::Normal(normal) = &attr.kind { + if pprust::path_to_string(&normal.item.path) != path { continue; } } diff --git a/src/tools/rustfmt/src/visitor.rs b/src/tools/rustfmt/src/visitor.rs index 9a0e0752c12..7bb745eeb8b 100644 --- a/src/tools/rustfmt/src/visitor.rs +++ b/src/tools/rustfmt/src/visitor.rs @@ -811,8 +811,8 @@ impl<'b, 'a: 'b> FmtVisitor<'a> { ); } else { match &attr.kind { - ast::AttrKind::Normal(ref attribute_item, _) - if self.is_unknown_rustfmt_attr(&attribute_item.path.segments) => + ast::AttrKind::Normal(ref normal) + if self.is_unknown_rustfmt_attr(&normal.item.path.segments) => { let file_name = self.parse_sess.span_to_filename(attr.span); self.report.append( |
