about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Lamparski <diagonaldevice@gmail.com>2018-06-11 19:44:48 -0400
committerMichael Lamparski <diagonaldevice@gmail.com>2018-06-12 08:06:22 -0400
commitd13bfd294c55a47bb33e5846ce184c80cdf547dd (patch)
tree5436d10742b351977add2194323898c8f802c148
parenta20c177827deb7687856e48dbbace63a22408a07 (diff)
downloadrust-d13bfd294c55a47bb33e5846ce184c80cdf547dd.tar.gz
rust-d13bfd294c55a47bb33e5846ce184c80cdf547dd.zip
fix issue #51331 by updating qself.position
-rw-r--r--src/librustc_resolve/macros.rs25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index fe6909f7591..de7a3dc5cee 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -138,7 +138,23 @@ impl<'a> base::Resolver for Resolver<'a> {
         struct EliminateCrateVar<'b, 'a: 'b>(&'b mut Resolver<'a>, Span);
 
         impl<'a, 'b> Folder for EliminateCrateVar<'a, 'b> {
-            fn fold_path(&mut self, mut path: ast::Path) -> ast::Path {
+            fn fold_path(&mut self, path: ast::Path) -> ast::Path {
+                match self.fold_qpath(None, path) {
+                    (None, path) => path,
+                    _ => unreachable!(),
+                }
+            }
+
+            fn fold_qpath(&mut self, mut qself: Option<ast::QSelf>, mut path: ast::Path)
+                          -> (Option<ast::QSelf>, ast::Path) {
+                qself = qself.map(|ast::QSelf { ty, path_span, position }| {
+                    ast::QSelf {
+                        ty: self.fold_ty(ty),
+                        path_span: self.new_span(path_span),
+                        position,
+                    }
+                });
+
                 let ident = path.segments[0].ident;
                 if ident.name == keywords::DollarCrate.name() {
                     path.segments[0].ident.name = keywords::CrateRoot.name();
@@ -150,10 +166,13 @@ impl<'a> base::Resolver for Resolver<'a> {
                                 ast::Ident::with_empty_ctxt(name).with_span_pos(span)
                             ),
                             _ => unreachable!(),
-                        })
+                        });
+                        if let Some(qself) = &mut qself {
+                            qself.position += 1;
+                        }
                     }
                 }
-                path
+                (qself, path)
             }
 
             fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {