mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-17 05:25:37 +03:00
Add HygieneData::adjust.
This commit is contained in:
@@ -243,6 +243,14 @@ fn remove_mark(&self, ctxt: &mut SyntaxContext) -> Mark {
|
||||
*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 @@ pub fn marks(mut self) -> Vec<(Mark, Transparency)> {
|
||||
/// 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
|
||||
|
||||
Reference in New Issue
Block a user