Skip to content

Commit d2dc21d

Browse files
Add documentation for SyntaxContext::remove_mark
1 parent 725c9b0 commit d2dc21d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/libsyntax_pos/hygiene.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,22 @@ impl SyntaxContext {
238238
})
239239
}
240240

241+
/// Pulls a single mark off of the syntax context. This effectively moves the
242+
/// context up one macro definition level. That is, if we have a nested macro
243+
/// definition as follows:
244+
///
245+
/// ```rust
246+
/// macro_rules! f {
247+
/// macro_rules! g {
248+
/// ...
249+
/// }
250+
/// }
251+
/// ```
252+
///
253+
/// and we have a SyntaxContext that is referring to something declared by an invocation
254+
/// of g (call it g1), calling remove_mark will result in the SyntaxContext for the
255+
/// invocation of f that created g1.
256+
/// Returns the mark that was removed.
241257
pub fn remove_mark(&mut self) -> Mark {
242258
HygieneData::with(|data| {
243259
let outer_mark = data.syntax_contexts[self.0 as usize].outer_mark;

0 commit comments

Comments
 (0)