From 1a48d1a4de1e26e08780a026daed3c7db743ff2f Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 20 May 2021 10:42:18 +0200 Subject: [PATCH] Add documentation and FIXME --- src/librustdoc/html/render/span_map.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index daeb43b77db..e168e41b832 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -97,16 +97,20 @@ struct SpanMapVisitor<'tcx> { } impl<'tcx> SpanMapVisitor<'tcx> { - fn handle_path(&mut self, path: &rustc_hir::Path<'_>, path_span: Option) -> bool { + /// This function is where we handle `hir::Path` elements and add them into the "span map". + fn handle_path(&mut self, path: &rustc_hir::Path<'_>, path_span: Option) { let info = match path.res { + // FIXME: For now, we only handle `DefKind` if it's not `DefKind::TyParam` or + // `DefKind::Macro`. Would be nice to support them too alongside the other `DefKind` + // (such as primitive types!). Res::Def(kind, def_id) if kind != DefKind::TyParam => { if matches!(kind, DefKind::Macro(_)) { - return false; + return; } Some(def_id) } Res::Local(_) => None, - _ => return true, + _ => return, }; if let Some(span) = self.tcx.hir().res_span(path.res) { self.matches.insert( @@ -123,7 +127,6 @@ impl<'tcx> SpanMapVisitor<'tcx> { LinkFromSrc::External(def_id), ); } - true } }