Skip to content

Commit

Permalink
Properly reset orig_id when loading from incremental cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Jul 26, 2020
1 parent 7e0d3fd commit cf7bef3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/librustc_span/hygiene.rs
Expand Up @@ -947,10 +947,20 @@ pub fn decode_expn_id<

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

let expn_id = HygieneData::with(|hygiene_data| {
let expn_id = ExpnId(hygiene_data.expn_data.len() as u32);

// If we just deserialized an `ExpnData` owned by
// the local crate, its `orig_id` will be stale,
// so we need to update it to its own value.
// This only happens when we deserialize the incremental cache,
// since a crate will never decode its own metadata.
if expn_data.krate == LOCAL_CRATE {
expn_data.orig_id = Some(expn_id.0);
}

hygiene_data.expn_data.push(Some(expn_data));

// Drop lock() temporary early
Expand Down

0 comments on commit cf7bef3

Please sign in to comment.