Skip to content

Commit

Permalink
hygiene: Make sure expansion info is set at most once for a given Mark
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jun 23, 2018
1 parent 17f20be commit b15785b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libsyntax_pos/hygiene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ impl Mark {

#[inline]
pub fn set_expn_info(self, info: ExpnInfo) {
HygieneData::with(|data| data.marks[self.0 as usize].expn_info = Some(info))
HygieneData::with(|data| {
let old_info = &mut data.marks[self.0 as usize].expn_info;
if let Some(old_info) = old_info {
panic!("expansion info is reset for the mark {}\nold: {:#?}\nnew: {:#?}",
self.0, old_info, info);
}
*old_info = Some(info);
})
}

pub fn modern(mut self) -> Mark {
Expand Down

0 comments on commit b15785b

Please sign in to comment.