diff options
| author | Lukas Markeffsky <@> | 2023-07-21 23:10:07 +0200 |
|---|---|---|
| committer | Lukas Markeffsky <@> | 2023-07-22 12:27:25 +0200 |
| commit | bb98f3ad4d67db68292724d767a4fd41386c8d20 (patch) | |
| tree | 0d40e8285a3817ed7679d115763da74292fad957 /src/librustdoc/html | |
| parent | 9ebd8095fad4ab1bc23717139402e6b3a834020a (diff) | |
| download | rust-bb98f3ad4d67db68292724d767a4fd41386c8d20.tar.gz rust-bb98f3ad4d67db68292724d767a4fd41386c8d20.zip | |
fix doc links on `extern crate` items
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/format.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 1099c68b004..f60f40267d6 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -18,7 +18,7 @@ use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::DefKind; -use rustc_hir::def_id::DefId; +use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_metadata::creader::{CStore, LoadedMacro}; use rustc_middle::ty; use rustc_middle::ty::TyCtxt; @@ -662,6 +662,14 @@ pub(crate) fn href_with_root_path( // documented on their parent's page tcx.parent(did) } + DefKind::ExternCrate => { + // Link to the crate itself, not the `extern crate` item. + if let Some(local_did) = did.as_local() { + tcx.extern_mod_stmt_cnum(local_did).unwrap_or(LOCAL_CRATE).as_def_id() + } else { + did + } + } _ => did, }; let cache = cx.cache(); |
