Skip to content

Commit a02b2e3

Browse files
committed
Add HygieneData::marks.
1 parent 88fd7a8 commit a02b2e3

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/libsyntax_pos/hygiene.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ impl HygieneData {
244244
outer_mark
245245
}
246246

247+
fn marks(&self, mut ctxt: SyntaxContext) -> Vec<(Mark, Transparency)> {
248+
let mut marks = Vec::new();
249+
while ctxt != SyntaxContext::empty() {
250+
let outer_mark = self.outer(ctxt);
251+
let transparency = self.transparency(ctxt);
252+
let prev_ctxt = self.prev_ctxt(ctxt);
253+
marks.push((outer_mark, transparency));
254+
ctxt = prev_ctxt;
255+
}
256+
marks.reverse();
257+
marks
258+
}
259+
247260
fn adjust(&self, ctxt: &mut SyntaxContext, expansion: Mark) -> Option<Mark> {
248261
let mut scope = None;
249262
while !self.is_descendant_of(expansion, self.outer(*ctxt)) {
@@ -423,19 +436,8 @@ impl SyntaxContext {
423436
HygieneData::with(|data| data.remove_mark(self))
424437
}
425438

426-
pub fn marks(mut self) -> Vec<(Mark, Transparency)> {
427-
HygieneData::with(|data| {
428-
let mut marks = Vec::new();
429-
while self != SyntaxContext::empty() {
430-
let outer_mark = data.outer(self);
431-
let transparency = data.transparency(self);
432-
let prev_ctxt = data.prev_ctxt(self);
433-
marks.push((outer_mark, transparency));
434-
self = prev_ctxt;
435-
}
436-
marks.reverse();
437-
marks
438-
})
439+
pub fn marks(self) -> Vec<(Mark, Transparency)> {
440+
HygieneData::with(|data| data.marks(self))
439441
}
440442

441443
/// Adjust this context for resolution in a scope created by the given expansion.

0 commit comments

Comments
 (0)