Move modern
calls inside glob_adjust
and reverse_glob_adjust
.
This commit is contained in:
parent
97c9437585
commit
8797e8cabd
@ -4525,7 +4525,7 @@ impl<'a> Resolver<'a> {
|
||||
let mut ident = ident;
|
||||
if ident.span.glob_adjust(
|
||||
module.expansion,
|
||||
binding.span.ctxt().modern(),
|
||||
binding.span,
|
||||
).is_none() {
|
||||
continue
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ impl<'a> Resolver<'a> {
|
||||
None => return Err((Undetermined, Weak::Yes)),
|
||||
};
|
||||
let (orig_current_module, mut ident) = (self.current_module, ident.modern());
|
||||
match ident.span.glob_adjust(module.expansion, glob_import.span.ctxt().modern()) {
|
||||
match ident.span.glob_adjust(module.expansion, glob_import.span) {
|
||||
Some(Some(def)) => self.current_module = self.macro_def_scope(def),
|
||||
Some(None) => {}
|
||||
None => continue,
|
||||
@ -605,8 +605,7 @@ impl<'a> Resolver<'a> {
|
||||
// Define `binding` in `module`s glob importers.
|
||||
for directive in module.glob_importers.borrow_mut().iter() {
|
||||
let mut ident = ident.modern();
|
||||
let scope = match ident.span.reverse_glob_adjust(module.expansion,
|
||||
directive.span.ctxt().modern()) {
|
||||
let scope = match ident.span.reverse_glob_adjust(module.expansion, directive.span) {
|
||||
Some(Some(def)) => self.macro_def_scope(def),
|
||||
Some(None) => directive.parent_scope.module,
|
||||
None => continue,
|
||||
@ -1359,8 +1358,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
|
||||
resolution.borrow().binding().map(|binding| (ident, binding))
|
||||
}).collect::<Vec<_>>();
|
||||
for ((mut ident, ns), binding) in bindings {
|
||||
let scope = match ident.span.reverse_glob_adjust(module.expansion,
|
||||
directive.span.ctxt().modern()) {
|
||||
let scope = match ident.span.reverse_glob_adjust(module.expansion, directive.span) {
|
||||
Some(Some(def)) => self.macro_def_scope(def),
|
||||
Some(None) => self.current_module,
|
||||
None => continue,
|
||||
|
@ -463,9 +463,9 @@ impl SyntaxContext {
|
||||
/// ```
|
||||
/// This returns `None` if the context cannot be glob-adjusted.
|
||||
/// Otherwise, it returns the scope to use when privacy checking (see `adjust` for details).
|
||||
pub fn glob_adjust(&mut self, expansion: Mark, mut glob_ctxt: SyntaxContext)
|
||||
-> Option<Option<Mark>> {
|
||||
pub fn glob_adjust(&mut self, expansion: Mark, glob_span: Span) -> Option<Option<Mark>> {
|
||||
let mut scope = None;
|
||||
let mut glob_ctxt = glob_span.ctxt().modern();
|
||||
while !expansion.outer_is_descendant_of(glob_ctxt) {
|
||||
scope = Some(glob_ctxt.remove_mark());
|
||||
if self.remove_mark() != scope.unwrap() {
|
||||
@ -485,12 +485,13 @@ impl SyntaxContext {
|
||||
/// assert!(self.glob_adjust(expansion, glob_ctxt) == Some(privacy_checking_scope));
|
||||
/// }
|
||||
/// ```
|
||||
pub fn reverse_glob_adjust(&mut self, expansion: Mark, mut glob_ctxt: SyntaxContext)
|
||||
pub fn reverse_glob_adjust(&mut self, expansion: Mark, glob_span: Span)
|
||||
-> Option<Option<Mark>> {
|
||||
if self.adjust(expansion).is_some() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut glob_ctxt = glob_span.ctxt().modern();
|
||||
let mut marks = Vec::new();
|
||||
while !expansion.outer_is_descendant_of(glob_ctxt) {
|
||||
marks.push(glob_ctxt.remove_mark());
|
||||
|
@ -535,19 +535,18 @@ impl Span {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn glob_adjust(&mut self, expansion: Mark, glob_ctxt: SyntaxContext)
|
||||
-> Option<Option<Mark>> {
|
||||
pub fn glob_adjust(&mut self, expansion: Mark, glob_span: Span) -> Option<Option<Mark>> {
|
||||
let mut span = self.data();
|
||||
let mark = span.ctxt.glob_adjust(expansion, glob_ctxt);
|
||||
let mark = span.ctxt.glob_adjust(expansion, glob_span);
|
||||
*self = Span::new(span.lo, span.hi, span.ctxt);
|
||||
mark
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn reverse_glob_adjust(&mut self, expansion: Mark, glob_ctxt: SyntaxContext)
|
||||
pub fn reverse_glob_adjust(&mut self, expansion: Mark, glob_span: Span)
|
||||
-> Option<Option<Mark>> {
|
||||
let mut span = self.data();
|
||||
let mark = span.ctxt.reverse_glob_adjust(expansion, glob_ctxt);
|
||||
let mark = span.ctxt.reverse_glob_adjust(expansion, glob_span);
|
||||
*self = Span::new(span.lo, span.hi, span.ctxt);
|
||||
mark
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user