Skip to content

Commit cf7bef3

Browse files
committed
Properly reset orig_id when loading from incremental cache
1 parent 7e0d3fd commit cf7bef3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/librustc_span/hygiene.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,20 @@ pub fn decode_expn_id<
947947

948948
// Don't decode the data inside `HygieneData::with`, since we need to recursively decode
949949
// other ExpnIds
950-
let expn_data = decode_data(d, index)?;
950+
let mut expn_data = decode_data(d, index)?;
951951

952952
let expn_id = HygieneData::with(|hygiene_data| {
953953
let expn_id = ExpnId(hygiene_data.expn_data.len() as u32);
954+
955+
// If we just deserialized an `ExpnData` owned by
956+
// the local crate, its `orig_id` will be stale,
957+
// so we need to update it to its own value.
958+
// This only happens when we deserialize the incremental cache,
959+
// since a crate will never decode its own metadata.
960+
if expn_data.krate == LOCAL_CRATE {
961+
expn_data.orig_id = Some(expn_id.0);
962+
}
963+
954964
hygiene_data.expn_data.push(Some(expn_data));
955965

956966
// Drop lock() temporary early

0 commit comments

Comments
 (0)