From 30716855056045650e88a98e9d6240ef33c33758 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 20 Feb 2021 15:05:50 +0100 Subject: [PATCH] Don't render [src] link on dummy spans --- src/librustdoc/clean/types.rs | 4 ++++ src/librustdoc/html/render/mod.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3e7196fa7fa..9a2319f6e37 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1852,6 +1852,10 @@ impl Span { self.0 } + crate fn is_dummy(&self) -> bool { + self.0.is_dummy() + } + crate fn filename(&self, sess: &Session) -> FileName { sess.source_map().span_to_filename(self.0) } diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index f5eb92c1bb5..7ca355ed11c 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1638,6 +1638,9 @@ impl Context<'_> { /// may happen, for example, with externally inlined items where the source /// of their crate documentation isn't known. fn src_href(&self, item: &clean::Item) -> Option { + if item.source.is_dummy() { + return None; + } let mut root = self.root_path(); let mut path = String::new(); let cnum = item.source.cnum(self.sess());