Skip to content

Commit 7a5b759

Browse files
Add support for trait associated items
1 parent 0a62c9e commit 7a5b759

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/librustdoc/html/render/span_map.rs

+18
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,24 @@ impl<'tcx> Visitor<'tcx> for SpanMapVisitor<'tcx> {
231231
self.handle_pat(p);
232232
}
233233

234+
fn visit_qpath(&mut self, qpath: &QPath<'tcx>, id: HirId, span: Span) {
235+
match *qpath {
236+
QPath::TypeRelative(qself, segment) => {
237+
self.infer_id(segment.hir_id, Some(id), span);
238+
239+
rustc_ast::visit::try_visit!(self.visit_ty(qself));
240+
self.visit_path_segment(segment);
241+
}
242+
QPath::Resolved(maybe_qself, path) => {
243+
self.handle_path(path);
244+
245+
rustc_ast::visit::visit_opt!(self, visit_ty, maybe_qself);
246+
self.visit_path(path, id)
247+
}
248+
_ => {}
249+
}
250+
}
251+
234252
fn visit_mod(&mut self, m: &'tcx Mod<'tcx>, span: Span, id: HirId) {
235253
// To make the difference between "mod foo {}" and "mod foo;". In case we "import" another
236254
// file, we want to link to it. Otherwise no need to create a link.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ compile-flags: -Zunstable-options --generate-link-to-definition
2+
3+
#![crate_name = "foo"]
4+
5+
pub enum Ty {
6+
Var,
7+
}
8+
9+
//@ has 'src/foo/jump-to-def-assoc-items.rs.html'
10+
//@ has - '//a[@href="#6"]' 'Self::Var'
11+
impl Ty {
12+
fn f() {
13+
let _ = Self::Var;
14+
}
15+
}

0 commit comments

Comments
 (0)