Skip to content

Commit d13bfd2

Browse files
committed
fix issue rust-lang#51331 by updating qself.position
1 parent a20c177 commit d13bfd2

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/librustc_resolve/macros.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,23 @@ impl<'a> base::Resolver for Resolver<'a> {
138138
struct EliminateCrateVar<'b, 'a: 'b>(&'b mut Resolver<'a>, Span);
139139

140140
impl<'a, 'b> Folder for EliminateCrateVar<'a, 'b> {
141-
fn fold_path(&mut self, mut path: ast::Path) -> ast::Path {
141+
fn fold_path(&mut self, path: ast::Path) -> ast::Path {
142+
match self.fold_qpath(None, path) {
143+
(None, path) => path,
144+
_ => unreachable!(),
145+
}
146+
}
147+
148+
fn fold_qpath(&mut self, mut qself: Option<ast::QSelf>, mut path: ast::Path)
149+
-> (Option<ast::QSelf>, ast::Path) {
150+
qself = qself.map(|ast::QSelf { ty, path_span, position }| {
151+
ast::QSelf {
152+
ty: self.fold_ty(ty),
153+
path_span: self.new_span(path_span),
154+
position,
155+
}
156+
});
157+
142158
let ident = path.segments[0].ident;
143159
if ident.name == keywords::DollarCrate.name() {
144160
path.segments[0].ident.name = keywords::CrateRoot.name();
@@ -150,10 +166,13 @@ impl<'a> base::Resolver for Resolver<'a> {
150166
ast::Ident::with_empty_ctxt(name).with_span_pos(span)
151167
),
152168
_ => unreachable!(),
153-
})
169+
});
170+
if let Some(qself) = &mut qself {
171+
qself.position += 1;
172+
}
154173
}
155174
}
156-
path
175+
(qself, path)
157176
}
158177

159178
fn fold_mac(&mut self, mac: ast::Mac) -> ast::Mac {

0 commit comments

Comments
 (0)