diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-04-20 17:42:06 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2021-08-05 23:08:28 +0200 |
| commit | 2a3b71ae33e1b5c4f8cecf32492f69a05faa7d93 (patch) | |
| tree | 0c877ecd9ef2df205d5e4fc3e728c121ada1f513 /src/librustdoc/html/render | |
| parent | b5c27b49d02d5b6538e40e19e0dd1365cd7632d5 (diff) | |
| download | rust-2a3b71ae33e1b5c4f8cecf32492f69a05faa7d93.tar.gz rust-2a3b71ae33e1b5c4f8cecf32492f69a05faa7d93.zip | |
* Rename 'move_span' into 'local_span_to_global_span'
* Add documentation on new arguments/functions
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/span_map.rs | 17 |
1 files changed, 17 insertions, 0 deletions
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, |
