Skip to content

Commit

Permalink
Add HygieneData::remove_mark.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Jun 4, 2019
1 parent 7bec8c9 commit cd64cc8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/libsyntax_pos/hygiene.rs
Expand Up @@ -237,6 +237,12 @@ impl HygieneData {
fn prev_ctxt(&self, ctxt: SyntaxContext) -> SyntaxContext {
self.syntax_contexts[ctxt.0 as usize].prev_ctxt
}

fn remove_mark(&self, ctxt: &mut SyntaxContext) -> Mark {
let outer_mark = self.syntax_contexts[ctxt.0 as usize].outer_mark;
*ctxt = self.prev_ctxt(*ctxt);
outer_mark
}
}

pub fn clear_markings() {
Expand Down Expand Up @@ -406,11 +412,7 @@ impl SyntaxContext {
/// invocation of f that created g1.
/// Returns the mark that was removed.
pub fn remove_mark(&mut self) -> Mark {
HygieneData::with(|data| {
let outer_mark = data.syntax_contexts[self.0 as usize].outer_mark;
*self = data.prev_ctxt(*self);
outer_mark
})
HygieneData::with(|data| data.remove_mark(self))
}

pub fn marks(mut self) -> Vec<(Mark, Transparency)> {
Expand Down

0 comments on commit cd64cc8

Please sign in to comment.