Address comments
This commit is contained in:
@@ -1434,9 +1434,12 @@ pub mod __internal {
|
|||||||
CURRENT_SESS.with(|p| {
|
CURRENT_SESS.with(|p| {
|
||||||
let _reset = Reset { prev: p.get() };
|
let _reset = Reset { prev: p.get() };
|
||||||
|
|
||||||
// No way to determine def location for a proc macro rigth now, so use call location.
|
// No way to determine def location for a proc macro right now, so use call location.
|
||||||
let location = cx.current_expansion.mark.expn_info().unwrap().call_site;
|
let location = cx.current_expansion.mark.expn_info().unwrap().call_site;
|
||||||
// Opaque mark was already created by expansion, now create its transparent twin.
|
// Opaque mark was already created by expansion, now create its transparent twin.
|
||||||
|
// We can't use the call-site span literally here, even if it appears to provide
|
||||||
|
// correct name resolution, because it has all the `ExpnInfo` wrong, so the edition
|
||||||
|
// checks, lint macro checks, macro backtraces will all break.
|
||||||
let opaque_mark = cx.current_expansion.mark;
|
let opaque_mark = cx.current_expansion.mark;
|
||||||
let transparent_mark = Mark::fresh_cloned(opaque_mark);
|
let transparent_mark = Mark::fresh_cloned(opaque_mark);
|
||||||
transparent_mark.set_transparency(Transparency::Transparent);
|
transparent_mark.set_transparency(Transparency::Transparent);
|
||||||
|
|||||||
@@ -2005,10 +2005,9 @@ impl<'a> Resolver<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Then find the last legacy mark from the end if it exists.
|
// Then find the last legacy mark from the end if it exists.
|
||||||
while let Some(&mark) = iter.peek() {
|
for mark in iter {
|
||||||
if mark.transparency() == Transparency::SemiTransparent {
|
if mark.transparency() == Transparency::SemiTransparent {
|
||||||
result = Some(mark);
|
result = Some(mark);
|
||||||
iter.next();
|
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ struct MarkData {
|
|||||||
pub enum Transparency {
|
pub enum Transparency {
|
||||||
/// Identifier produced by a transparent expansion is always resolved at call-site.
|
/// Identifier produced by a transparent expansion is always resolved at call-site.
|
||||||
/// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this.
|
/// Call-site spans in procedural macros, hygiene opt-out in `macro` should use this.
|
||||||
/// (Not used yet.)
|
|
||||||
Transparent,
|
Transparent,
|
||||||
/// Identifier produced by a semi-transparent expansion may be resolved
|
/// Identifier produced by a semi-transparent expansion may be resolved
|
||||||
/// either at call-site or at definition-site.
|
/// either at call-site or at definition-site.
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ impl Ident {
|
|||||||
Ident::new(self.name, self.span.modern())
|
Ident::new(self.name, self.span.modern())
|
||||||
}
|
}
|
||||||
|
|
||||||
// "Normalize" ident for use in comparisons using "local variable hygiene".
|
/// "Normalize" ident for use in comparisons using "local variable hygiene".
|
||||||
// Identifiers with same string value become same if they came from the same non-transparent
|
/// Identifiers with same string value become same if they came from the same non-transparent
|
||||||
// macro (e.g. `macro` or `macro_rules!` items) and stay different if they came from different
|
/// macro (e.g. `macro` or `macro_rules!` items) and stay different if they came from different
|
||||||
// non-transparent macros.
|
/// non-transparent macros.
|
||||||
// Technically, this operation strips all transparent marks from ident's syntactic context.
|
/// Technically, this operation strips all transparent marks from ident's syntactic context.
|
||||||
pub fn modern_and_legacy(self) -> Ident {
|
pub fn modern_and_legacy(self) -> Ident {
|
||||||
Ident::new(self.name, self.span.modern_and_legacy())
|
Ident::new(self.name, self.span.modern_and_legacy())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user