diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-06-01 07:44:14 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-06-05 07:43:14 +1000 |
| commit | 88fd7a8eb7a0d0ada3e33060969ccd91cba0132b (patch) | |
| tree | 703501953cf6415cb4a3d48efb32d3dabb5fe8de /src/libsyntax_pos | |
| parent | cd64cc835dc8342a596222a7f82646adcf1cbca6 (diff) | |
| download | rust-88fd7a8eb7a0d0ada3e33060969ccd91cba0132b.tar.gz rust-88fd7a8eb7a0d0ada3e33060969ccd91cba0132b.zip | |
Add `HygieneData::adjust`.
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/hygiene.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index 97fbd228e26..e8dadf09648 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -243,6 +243,14 @@ impl HygieneData { *ctxt = self.prev_ctxt(*ctxt); outer_mark } + + fn adjust(&self, ctxt: &mut SyntaxContext, expansion: Mark) -> Option<Mark> { + let mut scope = None; + while !self.is_descendant_of(expansion, self.outer(*ctxt)) { + scope = Some(self.remove_mark(ctxt)); + } + scope + } } pub fn clear_markings() { @@ -455,11 +463,7 @@ impl SyntaxContext { /// This returns the expansion whose definition scope we use to privacy check the resolution, /// or `None` if we privacy check as usual (i.e., not w.r.t. a macro definition scope). pub fn adjust(&mut self, expansion: Mark) -> Option<Mark> { - let mut scope = None; - while !expansion.outer_is_descendant_of(*self) { - scope = Some(self.remove_mark()); - } - scope + HygieneData::with(|data| data.adjust(self, expansion)) } /// Adjust this context for resolution in a scope created by the given expansion |
