@@ -179,14 +179,12 @@ impl LocalExpnId {
179
179
}
180
180
181
181
#[ inline]
182
- pub fn set_expn_data ( self , mut expn_data : ExpnData , ctx : impl HashStableContext ) {
182
+ pub fn set_expn_data ( self , expn_data : ExpnData , ctx : impl HashStableContext ) {
183
183
debug_assert_eq ! ( expn_data. parent. krate, LOCAL_CRATE ) ;
184
184
HygieneData :: with ( |data| {
185
185
let old_expn_data = & mut data. local_expn_data [ self ] ;
186
186
assert ! ( old_expn_data. is_none( ) , "expansion data is reset for an expansion ID" ) ;
187
- assert_eq ! ( expn_data. orig_id, None ) ;
188
187
debug_assert_eq ! ( expn_data. krate, LOCAL_CRATE ) ;
189
- expn_data. orig_id = Some ( self . as_u32 ( ) ) ;
190
188
* old_expn_data = Some ( expn_data) ;
191
189
} ) ;
192
190
update_disambiguator ( self , ctx)
@@ -306,14 +304,13 @@ pub struct HygieneData {
306
304
307
305
impl HygieneData {
308
306
crate fn new ( edition : Edition ) -> Self {
309
- let mut root_data = ExpnData :: default (
307
+ let root_data = ExpnData :: default (
310
308
ExpnKind :: Root ,
311
309
DUMMY_SP ,
312
310
edition,
313
311
Some ( CRATE_DEF_ID . to_def_id ( ) ) ,
314
312
None ,
315
313
) ;
316
- root_data. orig_id = Some ( 0 ) ;
317
314
318
315
HygieneData {
319
316
local_expn_data : IndexVec :: from_elem_n ( Some ( root_data) , 1 ) ,
@@ -339,13 +336,11 @@ impl HygieneData {
339
336
with_session_globals ( |session_globals| f ( & mut * session_globals. hygiene_data . borrow_mut ( ) ) )
340
337
}
341
338
342
- fn fresh_expn ( & mut self , mut expn_data : Option < ExpnData > ) -> LocalExpnId {
343
- let expn_id = self . local_expn_data . next_index ( ) ;
344
- if let Some ( data) = expn_data. as_mut ( ) {
339
+ fn fresh_expn ( & mut self , expn_data : Option < ExpnData > ) -> LocalExpnId {
340
+ if let Some ( data) = & expn_data {
345
341
debug_assert_eq ! ( data. krate, LOCAL_CRATE ) ;
346
- assert_eq ! ( data. orig_id, None ) ;
347
- data. orig_id = Some ( expn_id. as_u32 ( ) ) ;
348
342
}
343
+ let expn_id = self . local_expn_data . next_index ( ) ;
349
344
self . local_expn_data . push ( expn_data) ;
350
345
let _eid = self . local_expn_hashes . push ( ExpnHash ( Fingerprint :: ZERO ) ) ;
351
346
debug_assert_eq ! ( expn_id, _eid) ;
@@ -884,14 +879,6 @@ pub struct ExpnData {
884
879
/// foreign `ExpnId`s will have their `ExpnData` looked up
885
880
/// from the crate specified by `Crate
886
881
krate : CrateNum ,
887
- /// The raw that this `ExpnData` had in its original crate.
888
- /// An `ExpnData` can be created before being assigned an `ExpnId`,
889
- /// so this might be `None` until `set_expn_data` is called
890
- // This is used only for serialization/deserialization purposes:
891
- // two `ExpnData`s that differ only in their `orig_id` should
892
- // be considered equivalent.
893
- #[ stable_hasher( ignore) ]
894
- orig_id : Option < u32 > ,
895
882
/// Used to force two `ExpnData`s to have different `Fingerprint`s.
896
883
/// Due to macro expansion, it's possible to end up with two `ExpnId`s
897
884
/// that have identical `ExpnData`s. This violates the contract of `HashStable`
@@ -930,7 +917,6 @@ pub struct ExpnData {
930
917
pub parent_module : Option < DefId > ,
931
918
}
932
919
933
- // These would require special handling of `orig_id`.
934
920
impl !PartialEq for ExpnData { }
935
921
impl !Hash for ExpnData { }
936
922
@@ -959,7 +945,6 @@ impl ExpnData {
959
945
macro_def_id,
960
946
parent_module,
961
947
krate : LOCAL_CRATE ,
962
- orig_id : None ,
963
948
disambiguator : 0 ,
964
949
}
965
950
}
@@ -984,7 +969,6 @@ impl ExpnData {
984
969
macro_def_id,
985
970
parent_module,
986
971
krate : LOCAL_CRATE ,
987
- orig_id : None ,
988
972
disambiguator : 0 ,
989
973
}
990
974
}
@@ -1222,15 +1206,9 @@ pub struct HygieneDecodeContext {
1222
1206
}
1223
1207
1224
1208
/// Register an expansion which has been decoded from the on-disk-cache for the local crate.
1225
- pub fn register_local_expn_id ( mut data : ExpnData , hash : ExpnHash ) -> ExpnId {
1209
+ pub fn register_local_expn_id ( data : ExpnData , hash : ExpnHash ) -> ExpnId {
1226
1210
HygieneData :: with ( |hygiene_data| {
1227
- // If we just deserialized an `ExpnData` owned by
1228
- // the local crate, its `orig_id` will be stale,
1229
- // so we need to update it to its own value.
1230
- // This only happens when we deserialize the incremental cache,
1231
- // since a crate will never decode its own metadata.
1232
1211
let expn_id = hygiene_data. local_expn_data . next_index ( ) ;
1233
- data. orig_id = Some ( expn_id. as_u32 ( ) ) ;
1234
1212
hygiene_data. local_expn_data . push ( Some ( data) ) ;
1235
1213
let _eid = hygiene_data. local_expn_hashes . push ( hash) ;
1236
1214
debug_assert_eq ! ( expn_id, _eid) ;
@@ -1244,9 +1222,8 @@ pub fn register_local_expn_id(mut data: ExpnData, hash: ExpnHash) -> ExpnId {
1244
1222
}
1245
1223
1246
1224
/// Register an expansion which has been decoded from the metadata of a foreign crate.
1247
- pub fn register_expn_id ( data : ExpnData , hash : ExpnHash ) -> ExpnId {
1248
- let expn_id =
1249
- ExpnId { krate : data. krate , local_id : ExpnIndex :: from_u32 ( data. orig_id . unwrap ( ) ) } ;
1225
+ pub fn register_expn_id ( local_id : ExpnIndex , data : ExpnData , hash : ExpnHash ) -> ExpnId {
1226
+ let expn_id = ExpnId { krate : data. krate , local_id } ;
1250
1227
HygieneData :: with ( |hygiene_data| {
1251
1228
let _old_data = hygiene_data. foreign_expn_data . insert ( expn_id, data) ;
1252
1229
debug_assert ! ( _old_data. is_none( ) ) ;
@@ -1284,9 +1261,8 @@ pub fn decode_expn_id(
1284
1261
// other ExpnIds
1285
1262
let ( expn_data, hash) = decode_data ( expn_id) ;
1286
1263
debug_assert_eq ! ( krate, expn_data. krate) ;
1287
- debug_assert_eq ! ( Some ( index. as_u32( ) ) , expn_data. orig_id) ;
1288
1264
1289
- register_expn_id ( expn_data, hash)
1265
+ register_expn_id ( index , expn_data, hash)
1290
1266
}
1291
1267
1292
1268
// Decodes `SyntaxContext`, using the provided `HygieneDecodeContext`
0 commit comments