Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jun 29, 2018
1 parent b69d511 commit 84f1bc8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/libproc_macro/lib.rs
Expand Up @@ -1434,9 +1434,12 @@ pub mod __internal {
CURRENT_SESS.with(|p| {
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;
// 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 transparent_mark = Mark::fresh_cloned(opaque_mark);
transparent_mark.set_transparency(Transparency::Transparent);
Expand Down
3 changes: 1 addition & 2 deletions src/librustc_resolve/lib.rs
Expand Up @@ -2005,10 +2005,9 @@ impl<'a> Resolver<'a> {
}
}
// 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 {
result = Some(mark);
iter.next();
} else {
break;
}
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax_pos/hygiene.rs
Expand Up @@ -57,7 +57,6 @@ struct MarkData {
pub enum Transparency {
/// 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.
/// (Not used yet.)
Transparent,
/// Identifier produced by a semi-transparent expansion may be resolved
/// either at call-site or at definition-site.
Expand Down
10 changes: 5 additions & 5 deletions src/libsyntax_pos/symbol.rs
Expand Up @@ -68,11 +68,11 @@ impl Ident {
Ident::new(self.name, self.span.modern())
}

// "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
// macro (e.g. `macro` or `macro_rules!` items) and stay different if they came from different
// non-transparent macros.
// Technically, this operation strips all transparent marks from ident's syntactic context.
/// "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
/// macro (e.g. `macro` or `macro_rules!` items) and stay different if they came from different
/// non-transparent macros.
/// Technically, this operation strips all transparent marks from ident's syntactic context.
pub fn modern_and_legacy(self) -> Ident {
Ident::new(self.name, self.span.modern_and_legacy())
}
Expand Down

0 comments on commit 84f1bc8

Please sign in to comment.