Skip to content

Commit 88fd7a8

Browse files
committed
Add HygieneData::adjust.
1 parent cd64cc8 commit 88fd7a8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/libsyntax_pos/hygiene.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@ impl HygieneData {
243243
*ctxt = self.prev_ctxt(*ctxt);
244244
outer_mark
245245
}
246+
247+
fn adjust(&self, ctxt: &mut SyntaxContext, expansion: Mark) -> Option<Mark> {
248+
let mut scope = None;
249+
while !self.is_descendant_of(expansion, self.outer(*ctxt)) {
250+
scope = Some(self.remove_mark(ctxt));
251+
}
252+
scope
253+
}
246254
}
247255

248256
pub fn clear_markings() {
@@ -455,11 +463,7 @@ impl SyntaxContext {
455463
/// This returns the expansion whose definition scope we use to privacy check the resolution,
456464
/// or `None` if we privacy check as usual (i.e., not w.r.t. a macro definition scope).
457465
pub fn adjust(&mut self, expansion: Mark) -> Option<Mark> {
458-
let mut scope = None;
459-
while !expansion.outer_is_descendant_of(*self) {
460-
scope = Some(self.remove_mark());
461-
}
462-
scope
466+
HygieneData::with(|data| data.adjust(self, expansion))
463467
}
464468

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

0 commit comments

Comments
 (0)