Skip to content

Commit ac600cf

Browse files
committed
Stop relying on hashmap iteration for hir stat printing
Just because the code says it's OK does not mean that it actually is OK. Nodes with the same total size were not sorted, their order relied on hashmap iteration.
1 parent 0d04adf commit ac600cf

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

compiler/rustc_resolve/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ pub struct Resolver<'ra, 'tcx> {
11221122
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'ra>>,
11231123
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'ra>>,
11241124
unused_macros: FxHashMap<LocalDefId, (NodeId, Ident)>,
1125-
unused_macro_rules: FxHashMap<(LocalDefId, usize), (Ident, Span)>,
1125+
unused_macro_rules: FxIndexMap<(LocalDefId, usize), (Ident, Span)>,
11261126
proc_macro_stubs: FxHashSet<LocalDefId>,
11271127
/// Traces collected during macro resolution and validated when it's complete.
11281128
single_segment_macro_resolutions:

tests/ui/stats/hir-stats.stderr

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
ast-stats-1 PRE EXPANSION AST STATS
22
ast-stats-1 Name Accumulated Size Count Item Size
33
ast-stats-1 ----------------------------------------------------------------
4+
ast-stats-1 Crate 40 ( 0.6%) 1 40
45
ast-stats-1 GenericArgs 40 ( 0.6%) 1 40
56
ast-stats-1 - AngleBracketed 40 ( 0.6%) 1
6-
ast-stats-1 Crate 40 ( 0.6%) 1 40
77
ast-stats-1 ExprField 48 ( 0.7%) 1 48
88
ast-stats-1 WherePredicate 56 ( 0.8%) 1 56
99
ast-stats-1 - BoundPredicate 56 ( 0.8%) 1
1010
ast-stats-1 Attribute 64 ( 1.0%) 2 32
11-
ast-stats-1 - Normal 32 ( 0.5%) 1
1211
ast-stats-1 - DocComment 32 ( 0.5%) 1
12+
ast-stats-1 - Normal 32 ( 0.5%) 1
1313
ast-stats-1 Local 80 ( 1.2%) 1 80
1414
ast-stats-1 ForeignItem 88 ( 1.3%) 1 88
1515
ast-stats-1 - Fn 88 ( 1.3%) 1
1616
ast-stats-1 Arm 96 ( 1.4%) 2 48
1717
ast-stats-1 FnDecl 120 ( 1.8%) 5 24
1818
ast-stats-1 FieldDef 160 ( 2.4%) 2 80
19+
ast-stats-1 Param 160 ( 2.4%) 4 40
1920
ast-stats-1 Stmt 160 ( 2.4%) 5 32
2021
ast-stats-1 - Let 32 ( 0.5%) 1
2122
ast-stats-1 - MacCall 32 ( 0.5%) 1
2223
ast-stats-1 - Expr 96 ( 1.4%) 3
23-
ast-stats-1 Param 160 ( 2.4%) 4 40
2424
ast-stats-1 Block 192 ( 2.9%) 6 32
2525
ast-stats-1 Variant 208 ( 3.1%) 2 104
26-
ast-stats-1 GenericBound 352 ( 5.3%) 4 88
27-
ast-stats-1 - Trait 352 ( 5.3%) 4
2826
ast-stats-1 AssocItem 352 ( 5.3%) 4 88
2927
ast-stats-1 - Type 176 ( 2.7%) 2
3028
ast-stats-1 - Fn 176 ( 2.7%) 2
29+
ast-stats-1 GenericBound 352 ( 5.3%) 4 88
30+
ast-stats-1 - Trait 352 ( 5.3%) 4
3131
ast-stats-1 GenericParam 480 ( 7.2%) 5 96
3232
ast-stats-1 Pat 504 ( 7.6%) 7 72
3333
ast-stats-1 - Struct 72 ( 1.1%) 1
@@ -41,15 +41,15 @@ ast-stats-1 - Lit 144 ( 2.2%) 2
4141
ast-stats-1 - Block 216 ( 3.3%) 3
4242
ast-stats-1 PathSegment 744 (11.2%) 31 24
4343
ast-stats-1 Ty 896 (13.5%) 14 64
44-
ast-stats-1 - Ptr 64 ( 1.0%) 1
4544
ast-stats-1 - Ref 64 ( 1.0%) 1
45+
ast-stats-1 - Ptr 64 ( 1.0%) 1
4646
ast-stats-1 - ImplicitSelf 128 ( 1.9%) 2
4747
ast-stats-1 - Path 640 ( 9.6%) 10
4848
ast-stats-1 Item 1_224 (18.4%) 9 136
49-
ast-stats-1 - Trait 136 ( 2.0%) 1
50-
ast-stats-1 - Enum 136 ( 2.0%) 1
5149
ast-stats-1 - ForeignMod 136 ( 2.0%) 1
50+
ast-stats-1 - Trait 136 ( 2.0%) 1
5251
ast-stats-1 - Impl 136 ( 2.0%) 1
52+
ast-stats-1 - Enum 136 ( 2.0%) 1
5353
ast-stats-1 - Fn 272 ( 4.1%) 2
5454
ast-stats-1 - Use 408 ( 6.1%) 3
5555
ast-stats-1 ----------------------------------------------------------------
@@ -58,34 +58,34 @@ 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 Crate 40 ( 0.5%) 1 40
6162
ast-stats-2 GenericArgs 40 ( 0.5%) 1 40
6263
ast-stats-2 - AngleBracketed 40 ( 0.5%) 1
63-
ast-stats-2 Crate 40 ( 0.5%) 1 40
6464
ast-stats-2 ExprField 48 ( 0.7%) 1 48
6565
ast-stats-2 WherePredicate 56 ( 0.8%) 1 56
6666
ast-stats-2 - BoundPredicate 56 ( 0.8%) 1
6767
ast-stats-2 Local 80 ( 1.1%) 1 80
6868
ast-stats-2 ForeignItem 88 ( 1.2%) 1 88
6969
ast-stats-2 - Fn 88 ( 1.2%) 1
7070
ast-stats-2 Arm 96 ( 1.3%) 2 48
71-
ast-stats-2 InlineAsm 120 ( 1.6%) 1 120
7271
ast-stats-2 FnDecl 120 ( 1.6%) 5 24
72+
ast-stats-2 InlineAsm 120 ( 1.6%) 1 120
7373
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
77+
ast-stats-2 Param 160 ( 2.2%) 4 40
7778
ast-stats-2 Stmt 160 ( 2.2%) 5 32
7879
ast-stats-2 - Let 32 ( 0.4%) 1
7980
ast-stats-2 - Semi 32 ( 0.4%) 1
8081
ast-stats-2 - Expr 96 ( 1.3%) 3
81-
ast-stats-2 Param 160 ( 2.2%) 4 40
8282
ast-stats-2 Block 192 ( 2.6%) 6 32
8383
ast-stats-2 Variant 208 ( 2.9%) 2 104
84-
ast-stats-2 GenericBound 352 ( 4.8%) 4 88
85-
ast-stats-2 - Trait 352 ( 4.8%) 4
8684
ast-stats-2 AssocItem 352 ( 4.8%) 4 88
8785
ast-stats-2 - Type 176 ( 2.4%) 2
8886
ast-stats-2 - Fn 176 ( 2.4%) 2
87+
ast-stats-2 GenericBound 352 ( 4.8%) 4 88
88+
ast-stats-2 - Trait 352 ( 4.8%) 4
8989
ast-stats-2 GenericParam 480 ( 6.6%) 5 96
9090
ast-stats-2 Pat 504 ( 6.9%) 7 72
9191
ast-stats-2 - Struct 72 ( 1.0%) 1
@@ -100,16 +100,16 @@ ast-stats-2 - Lit 144 ( 2.0%) 2
100100
ast-stats-2 - Block 216 ( 3.0%) 3
101101
ast-stats-2 PathSegment 864 (11.9%) 36 24
102102
ast-stats-2 Ty 896 (12.3%) 14 64
103-
ast-stats-2 - Ptr 64 ( 0.9%) 1
104103
ast-stats-2 - Ref 64 ( 0.9%) 1
104+
ast-stats-2 - Ptr 64 ( 0.9%) 1
105105
ast-stats-2 - ImplicitSelf 128 ( 1.8%) 2
106106
ast-stats-2 - Path 640 ( 8.8%) 10
107107
ast-stats-2 Item 1_496 (20.5%) 11 136
108-
ast-stats-2 - Trait 136 ( 1.9%) 1
109108
ast-stats-2 - Enum 136 ( 1.9%) 1
109+
ast-stats-2 - Trait 136 ( 1.9%) 1
110+
ast-stats-2 - Impl 136 ( 1.9%) 1
110111
ast-stats-2 - ExternCrate 136 ( 1.9%) 1
111112
ast-stats-2 - ForeignMod 136 ( 1.9%) 1
112-
ast-stats-2 - Impl 136 ( 1.9%) 1
113113
ast-stats-2 - Fn 272 ( 3.7%) 2
114114
ast-stats-2 - Use 544 ( 7.5%) 4
115115
ast-stats-2 ----------------------------------------------------------------
@@ -129,8 +129,8 @@ hir-stats - Lifetime 48 ( 0.5%) 3
129129
hir-stats Local 64 ( 0.7%) 1 64
130130
hir-stats Param 64 ( 0.7%) 2 32
131131
hir-stats Body 72 ( 0.8%) 3 24
132-
hir-stats InlineAsm 72 ( 0.8%) 1 72
133132
hir-stats ImplItemRef 72 ( 0.8%) 2 36
133+
hir-stats InlineAsm 72 ( 0.8%) 1 72
134134
hir-stats Arm 80 ( 0.9%) 2 40
135135
hir-stats FieldDef 96 ( 1.1%) 2 48
136136
hir-stats Stmt 96 ( 1.1%) 3 32
@@ -139,36 +139,36 @@ hir-stats - Semi 32 ( 0.4%) 1
139139
hir-stats - Expr 32 ( 0.4%) 1
140140
hir-stats FnDecl 120 ( 1.3%) 3 40
141141
hir-stats Attribute 128 ( 1.4%) 4 32
142-
hir-stats Variant 144 ( 1.6%) 2 72
143142
hir-stats GenericArgs 144 ( 1.6%) 3 48
143+
hir-stats Variant 144 ( 1.6%) 2 72
144144
hir-stats GenericBound 192 ( 2.1%) 4 48
145145
hir-stats - Trait 192 ( 2.1%) 4
146146
hir-stats WherePredicate 192 ( 2.1%) 3 64
147147
hir-stats - BoundPredicate 192 ( 2.1%) 3
148148
hir-stats Block 288 ( 3.2%) 6 48
149149
hir-stats GenericParam 360 ( 4.0%) 5 72
150150
hir-stats Pat 360 ( 4.0%) 5 72
151-
hir-stats - Wild 72 ( 0.8%) 1
152151
hir-stats - Struct 72 ( 0.8%) 1
152+
hir-stats - Wild 72 ( 0.8%) 1
153153
hir-stats - Binding 216 ( 2.4%) 3
154154
hir-stats Generics 560 ( 6.2%) 10 56
155155
hir-stats Ty 720 ( 8.0%) 15 48
156-
hir-stats - Ptr 48 ( 0.5%) 1
157156
hir-stats - Ref 48 ( 0.5%) 1
157+
hir-stats - Ptr 48 ( 0.5%) 1
158158
hir-stats - Path 624 ( 7.0%) 13
159159
hir-stats Expr 768 ( 8.6%) 12 64
160160
hir-stats - Path 64 ( 0.7%) 1
161-
hir-stats - Struct 64 ( 0.7%) 1
162161
hir-stats - Match 64 ( 0.7%) 1
162+
hir-stats - Struct 64 ( 0.7%) 1
163163
hir-stats - InlineAsm 64 ( 0.7%) 1
164164
hir-stats - Lit 128 ( 1.4%) 2
165165
hir-stats - Block 384 ( 4.3%) 6
166166
hir-stats Item 968 (10.8%) 11 88
167-
hir-stats - Trait 88 ( 1.0%) 1
168167
hir-stats - Enum 88 ( 1.0%) 1
168+
hir-stats - Trait 88 ( 1.0%) 1
169+
hir-stats - Impl 88 ( 1.0%) 1
169170
hir-stats - ExternCrate 88 ( 1.0%) 1
170171
hir-stats - ForeignMod 88 ( 1.0%) 1
171-
hir-stats - Impl 88 ( 1.0%) 1
172172
hir-stats - Fn 176 ( 2.0%) 2
173173
hir-stats - Use 352 ( 3.9%) 4
174174
hir-stats Path 1_240 (13.8%) 31 40

0 commit comments

Comments
 (0)