@@ -179,14 +179,12 @@ impl LocalExpnId {
179179 }
180180
181181 #[ 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 ) {
183183 debug_assert_eq ! ( expn_data. parent. krate, LOCAL_CRATE ) ;
184184 HygieneData :: with ( |data| {
185185 let old_expn_data = & mut data. local_expn_data [ self ] ;
186186 assert ! ( old_expn_data. is_none( ) , "expansion data is reset for an expansion ID" ) ;
187- assert_eq ! ( expn_data. orig_id, None ) ;
188187 debug_assert_eq ! ( expn_data. krate, LOCAL_CRATE ) ;
189- expn_data. orig_id = Some ( self . as_u32 ( ) ) ;
190188 * old_expn_data = Some ( expn_data) ;
191189 } ) ;
192190 update_disambiguator ( self , ctx)
@@ -306,14 +304,13 @@ pub struct HygieneData {
306304
307305impl HygieneData {
308306 crate fn new ( edition : Edition ) -> Self {
309- let mut root_data = ExpnData :: default (
307+ let root_data = ExpnData :: default (
310308 ExpnKind :: Root ,
311309 DUMMY_SP ,
312310 edition,
313311 Some ( CRATE_DEF_ID . to_def_id ( ) ) ,
314312 None ,
315313 ) ;
316- root_data. orig_id = Some ( 0 ) ;
317314
318315 HygieneData {
319316 local_expn_data : IndexVec :: from_elem_n ( Some ( root_data) , 1 ) ,
@@ -339,13 +336,11 @@ impl HygieneData {
339336 with_session_globals ( |session_globals| f ( & mut * session_globals. hygiene_data . borrow_mut ( ) ) )
340337 }
341338
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 {
345341 debug_assert_eq ! ( data. krate, LOCAL_CRATE ) ;
346- assert_eq ! ( data. orig_id, None ) ;
347- data. orig_id = Some ( expn_id. as_u32 ( ) ) ;
348342 }
343+ let expn_id = self . local_expn_data . next_index ( ) ;
349344 self . local_expn_data . push ( expn_data) ;
350345 let _eid = self . local_expn_hashes . push ( ExpnHash ( Fingerprint :: ZERO ) ) ;
351346 debug_assert_eq ! ( expn_id, _eid) ;
@@ -884,14 +879,6 @@ pub struct ExpnData {
884879 /// foreign `ExpnId`s will have their `ExpnData` looked up
885880 /// from the crate specified by `Crate
886881 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 > ,
895882 /// Used to force two `ExpnData`s to have different `Fingerprint`s.
896883 /// Due to macro expansion, it's possible to end up with two `ExpnId`s
897884 /// that have identical `ExpnData`s. This violates the contract of `HashStable`
@@ -930,7 +917,6 @@ pub struct ExpnData {
930917 pub parent_module : Option < DefId > ,
931918}
932919
933- // These would require special handling of `orig_id`.
934920impl !PartialEq for ExpnData { }
935921impl !Hash for ExpnData { }
936922
@@ -959,7 +945,6 @@ impl ExpnData {
959945 macro_def_id,
960946 parent_module,
961947 krate : LOCAL_CRATE ,
962- orig_id : None ,
963948 disambiguator : 0 ,
964949 }
965950 }
@@ -984,7 +969,6 @@ impl ExpnData {
984969 macro_def_id,
985970 parent_module,
986971 krate : LOCAL_CRATE ,
987- orig_id : None ,
988972 disambiguator : 0 ,
989973 }
990974 }
@@ -1222,15 +1206,9 @@ pub struct HygieneDecodeContext {
12221206}
12231207
12241208/// 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 {
12261210 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.
12321211 let expn_id = hygiene_data. local_expn_data . next_index ( ) ;
1233- data. orig_id = Some ( expn_id. as_u32 ( ) ) ;
12341212 hygiene_data. local_expn_data . push ( Some ( data) ) ;
12351213 let _eid = hygiene_data. local_expn_hashes . push ( hash) ;
12361214 debug_assert_eq ! ( expn_id, _eid) ;
@@ -1244,9 +1222,8 @@ pub fn register_local_expn_id(mut data: ExpnData, hash: ExpnHash) -> ExpnId {
12441222}
12451223
12461224/// 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 } ;
12501227 HygieneData :: with ( |hygiene_data| {
12511228 let _old_data = hygiene_data. foreign_expn_data . insert ( expn_id, data) ;
12521229 debug_assert ! ( _old_data. is_none( ) ) ;
@@ -1284,9 +1261,8 @@ pub fn decode_expn_id(
12841261 // other ExpnIds
12851262 let ( expn_data, hash) = decode_data ( expn_id) ;
12861263 debug_assert_eq ! ( krate, expn_data. krate) ;
1287- debug_assert_eq ! ( Some ( index. as_u32( ) ) , expn_data. orig_id) ;
12881264
1289- register_expn_id ( expn_data, hash)
1265+ register_expn_id ( index , expn_data, hash)
12901266}
12911267
12921268// Decodes `SyntaxContext`, using the provided `HygieneDecodeContext`
0 commit comments