From 2a3b71ae33e1b5c4f8cecf32492f69a05faa7d93 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 20 Apr 2021 17:42:06 +0200 Subject: * Rename 'move_span' into 'local_span_to_global_span' * Add documentation on new arguments/functions --- src/librustdoc/html/render/span_map.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/librustdoc/html/render') diff --git a/src/librustdoc/html/render/span_map.rs b/src/librustdoc/html/render/span_map.rs index 6100f45e998..9e16c451626 100644 --- a/src/librustdoc/html/render/span_map.rs +++ b/src/librustdoc/html/render/span_map.rs @@ -9,12 +9,29 @@ use rustc_hir::{ExprKind, GenericParam, GenericParamKind, HirId, Mod, Node}; use rustc_middle::ty::TyCtxt; use rustc_span::Span; +/// This enum allows us to store two different kinds of information: +/// +/// In case the `span` definition comes from the same crate, we can simply get the `span` and use +/// it as is. +/// +/// Otherwise, we store the definition `DefId` and will generate a link to the documentation page +/// instead of the source code directly. #[derive(Debug)] crate enum LinkFromSrc { Local(Span), External(DefId), } +/// This function will do at most two things: +/// +/// 1. Generate a `span` correspondance map which links an item `span` to its definition `span`. +/// 2. Collect the source code files. +/// +/// It returns the `krate`, the source code files and the `span` correspondance map. +/// +/// Note about the `span` correspondance map: the keys are actually `(lo, hi)` of `span`s. We don't +/// need the `span` context later on, only their position, so instead of keep a whole `Span`, we +/// only keep the `lo` and `hi`. crate fn collect_spans_and_sources( tcx: TyCtxt<'_>, krate: clean::Crate, -- cgit 1.4.1-3-g733a5