@@ -184,7 +184,6 @@ impl LocalExpnId {
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
- debug_assert_eq ! ( expn_data. krate, LOCAL_CRATE ) ;
188
187
* old_expn_data = Some ( expn_data) ;
189
188
} ) ;
190
189
update_disambiguator ( self , ctx)
@@ -337,11 +336,7 @@ impl HygieneData {
337
336
}
338
337
339
338
fn fresh_expn ( & mut self , expn_data : Option < ExpnData > ) -> LocalExpnId {
340
- if let Some ( data) = & expn_data {
341
- debug_assert_eq ! ( data. krate, LOCAL_CRATE ) ;
342
- }
343
- let expn_id = self . local_expn_data . next_index ( ) ;
344
- self . local_expn_data . push ( expn_data) ;
339
+ let expn_id = self . local_expn_data . push ( expn_data) ;
345
340
let _eid = self . local_expn_hashes . push ( ExpnHash ( Fingerprint :: ZERO ) ) ;
346
341
debug_assert_eq ! ( expn_id, _eid) ;
347
342
expn_id
@@ -873,12 +868,6 @@ pub struct ExpnData {
873
868
/// call_site span would have its own ExpnData, with the call_site
874
869
/// pointing to the `foo!` invocation.
875
870
pub call_site : Span ,
876
- /// The crate that originally created this `ExpnData`. During
877
- /// metadata serialization, we only encode `ExpnData`s that were
878
- /// created locally - when our serialized metadata is decoded,
879
- /// foreign `ExpnId`s will have their `ExpnData` looked up
880
- /// from the crate specified by `Crate
881
- krate : CrateNum ,
882
871
/// Used to force two `ExpnData`s to have different `Fingerprint`s.
883
872
/// Due to macro expansion, it's possible to end up with two `ExpnId`s
884
873
/// that have identical `ExpnData`s. This violates the contract of `HashStable`
@@ -944,7 +933,6 @@ impl ExpnData {
944
933
edition,
945
934
macro_def_id,
946
935
parent_module,
947
- krate : LOCAL_CRATE ,
948
936
disambiguator : 0 ,
949
937
}
950
938
}
@@ -968,7 +956,6 @@ impl ExpnData {
968
956
edition,
969
957
macro_def_id,
970
958
parent_module,
971
- krate : LOCAL_CRATE ,
972
959
disambiguator : 0 ,
973
960
}
974
961
}
@@ -1222,8 +1209,13 @@ pub fn register_local_expn_id(data: ExpnData, hash: ExpnHash) -> ExpnId {
1222
1209
}
1223
1210
1224
1211
/// Register an expansion which has been decoded from the metadata of a foreign crate.
1225
- pub fn register_expn_id ( local_id : ExpnIndex , data : ExpnData , hash : ExpnHash ) -> ExpnId {
1226
- let expn_id = ExpnId { krate : data. krate , local_id } ;
1212
+ pub fn register_expn_id (
1213
+ krate : CrateNum ,
1214
+ local_id : ExpnIndex ,
1215
+ data : ExpnData ,
1216
+ hash : ExpnHash ,
1217
+ ) -> ExpnId {
1218
+ let expn_id = ExpnId { krate, local_id } ;
1227
1219
HygieneData :: with ( |hygiene_data| {
1228
1220
let _old_data = hygiene_data. foreign_expn_data . insert ( expn_id, data) ;
1229
1221
debug_assert ! ( _old_data. is_none( ) ) ;
@@ -1260,9 +1252,8 @@ pub fn decode_expn_id(
1260
1252
// Don't decode the data inside `HygieneData::with`, since we need to recursively decode
1261
1253
// other ExpnIds
1262
1254
let ( expn_data, hash) = decode_data ( expn_id) ;
1263
- debug_assert_eq ! ( krate, expn_data. krate) ;
1264
1255
1265
- register_expn_id ( index, expn_data, hash)
1256
+ register_expn_id ( krate , index, expn_data, hash)
1266
1257
}
1267
1258
1268
1259
// Decodes `SyntaxContext`, using the provided `HygieneDecodeContext`
@@ -1420,7 +1411,7 @@ impl<D: Decoder> Decodable<D> for SyntaxContext {
1420
1411
/// This method is called only when an `ExpnData` is first associated
1421
1412
/// with an `ExpnId` (when the `ExpnId` is initially constructed, or via
1422
1413
/// `set_expn_data`). It is *not* called for foreign `ExpnId`s deserialized
1423
- /// from another crate's metadata - since `ExpnData ` includes a `krate` field ,
1414
+ /// from another crate's metadata - since `ExpnHash ` includes the stable crate id ,
1424
1415
/// collisions are only possible between `ExpnId`s within the same crate.
1425
1416
fn update_disambiguator ( expn_id : LocalExpnId , mut ctx : impl HashStableContext ) {
1426
1417
let mut expn_data = expn_id. expn_data ( ) ;
0 commit comments