@@ -93,7 +93,7 @@ pub type TypeSource = InFile<TypePtr>;
93
93
pub type LifetimePtr = AstPtr < ast:: Lifetime > ;
94
94
pub type LifetimeSource = InFile < LifetimePtr > ;
95
95
96
- #[ derive( Debug , Eq , PartialEq ) ]
96
+ #[ derive( Debug , PartialEq , Eq ) ]
97
97
pub struct ExpressionStore {
98
98
pub exprs : Arena < Expr > ,
99
99
pub pats : Arena < Pat > ,
@@ -114,7 +114,7 @@ pub struct ExpressionStore {
114
114
ident_hygiene : FxHashMap < ExprOrPatId , HygieneId > ,
115
115
}
116
116
117
- #[ derive( Debug , Eq , PartialEq , Default ) ]
117
+ #[ derive( Debug , Eq , Default ) ]
118
118
pub struct ExpressionStoreSourceMap {
119
119
// AST expressions can create patterns in destructuring assignments. Therefore, `ExprSource` can also map
120
120
// to `PatId`, and `PatId` can also map to `ExprSource` (the other way around is unaffected).
@@ -127,19 +127,20 @@ pub struct ExpressionStoreSourceMap {
127
127
label_map : FxHashMap < LabelSource , LabelId > ,
128
128
label_map_back : ArenaMap < LabelId , LabelSource > ,
129
129
130
- binding_definitions : FxHashMap < BindingId , SmallVec < [ PatId ; 4 ] > > ,
131
-
132
- /// We don't create explicit nodes for record fields (`S { record_field: 92 }`).
133
- /// Instead, we use id of expression (`92`) to identify the field.
134
- field_map_back : FxHashMap < ExprId , FieldSource > ,
135
- pat_field_map_back : FxHashMap < PatId , PatFieldSource > ,
136
-
137
130
types_map_back : ArenaMap < TypeRefId , TypeSource > ,
138
131
types_map : FxHashMap < TypeSource , TypeRefId > ,
139
132
140
133
lifetime_map_back : ArenaMap < LifetimeRefId , LifetimeSource > ,
141
134
lifetime_map : FxHashMap < LifetimeSource , LifetimeRefId > ,
142
135
136
+ binding_definitions :
137
+ ArenaMap < BindingId , SmallVec < [ PatId ; 2 * size_of :: < usize > ( ) / size_of :: < PatId > ( ) ] > > ,
138
+
139
+ /// We don't create explicit nodes for record fields (`S { record_field: 92 }`).
140
+ /// Instead, we use id of expression (`92`) to identify the field.
141
+ field_map_back : FxHashMap < ExprId , FieldSource > ,
142
+ pat_field_map_back : FxHashMap < PatId , PatFieldSource > ,
143
+
143
144
template_map : Option < Box < FormatTemplate > > ,
144
145
145
146
pub expansions : FxHashMap < InFile < MacroCallPtr > , MacroCallId > ,
@@ -149,6 +150,43 @@ pub struct ExpressionStoreSourceMap {
149
150
pub diagnostics : Vec < ExpressionStoreDiagnostics > ,
150
151
}
151
152
153
+ impl PartialEq for ExpressionStoreSourceMap {
154
+ fn eq ( & self , other : & Self ) -> bool {
155
+ // we only need to compare one of the two mappings
156
+ // as the other is a reverse mapping and thus will compare
157
+ // the same as normal mapping
158
+ let Self {
159
+ expr_map : _,
160
+ expr_map_back,
161
+ pat_map : _,
162
+ pat_map_back,
163
+ label_map : _,
164
+ label_map_back,
165
+ types_map_back,
166
+ types_map : _,
167
+ lifetime_map_back,
168
+ lifetime_map : _,
169
+ // If this changed, our pattern data must have changed
170
+ binding_definitions : _,
171
+ // If this changed, our expression data must have changed
172
+ field_map_back : _,
173
+ // If this changed, our pattern data must have changed
174
+ pat_field_map_back : _,
175
+ template_map,
176
+ expansions,
177
+ diagnostics,
178
+ } = self ;
179
+ * expr_map_back == other. expr_map_back
180
+ && * pat_map_back == other. pat_map_back
181
+ && * label_map_back == other. label_map_back
182
+ && * types_map_back == other. types_map_back
183
+ && * lifetime_map_back == other. lifetime_map_back
184
+ && * template_map == other. template_map
185
+ && * expansions == other. expansions
186
+ && * diagnostics == other. diagnostics
187
+ }
188
+ }
189
+
152
190
/// The body of an item (function, const etc.).
153
191
#[ derive( Debug , Eq , PartialEq , Default ) ]
154
192
pub struct ExpressionStoreBuilder {
@@ -698,7 +736,7 @@ impl ExpressionStoreSourceMap {
698
736
}
699
737
700
738
pub fn patterns_for_binding ( & self , binding : BindingId ) -> & [ PatId ] {
701
- self . binding_definitions . get ( & binding) . map_or ( & [ ] , Deref :: deref)
739
+ self . binding_definitions . get ( binding) . map_or ( & [ ] , Deref :: deref)
702
740
}
703
741
704
742
pub fn node_label ( & self , node : InFile < & ast:: Label > ) -> Option < LabelId > {
0 commit comments