about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-06-30 01:53:17 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-06-30 01:53:32 +0300
commit84f1bc8b662da4ceb0e448bf0d24ce627e6a462b (patch)
treef43a60b5fbefba0ccb7fad613f5df8bfafebdc51
parentb69d51162b5391119e86d1c6e884aa09292a7806 (diff)
downloadrust-84f1bc8b662da4ceb0e448bf0d24ce627e6a462b.tar.gz
rust-84f1bc8b662da4ceb0e448bf0d24ce627e6a462b.zip
Address comments
-rw-r--r--src/libproc_macro/lib.rs5
-rw-r--r--src/librustc_resolve/lib.rs3
-rw-r--r--src/libsyntax_pos/hygiene.rs1
-rw-r--r--src/libsyntax_pos/symbol.rs10
4 files changed, 10 insertions, 9 deletions
diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs
index 820b0906a75..fb5cbf473a3 100644
--- a/src/libproc_macro/lib.rs
+++ b/src/libproc_macro/lib.rs
@@ -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);
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 9475b96d30b..8a32ec6978c 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -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;
                 }
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs
index e7f1f31084a..33d02d0b10a 100644
--- a/src/libsyntax_pos/hygiene.rs
+++ b/src/libsyntax_pos/hygiene.rs
@@ -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.
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index fe0b479d161..9a0c92f6793 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -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())
     }