hygiene: Make sure expansion info is set at most once for a given Mark

This commit is contained in:
Vadim Petrochenkov 2018-06-20 00:13:11 +03:00
parent 17f20bec22
commit b15785b671

View File

@ -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 {