about summary refs log tree commit diff
path: root/src/librustdoc/html/render/mod.rs
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2022-10-27 11:16:30 -0700
committerMichael Howell <michael@notriddle.com>2022-10-31 13:59:52 -0700
commit07bb2f701e5bae0da724068bbce1920458df9cda (patch)
treee66ce28d1066147abc87224fde63b4f6c39d8075 /src/librustdoc/html/render/mod.rs
parent2afca78a0b03db144c5d8b9f8868feebfe096309 (diff)
downloadrust-07bb2f701e5bae0da724068bbce1920458df9cda.tar.gz
rust-07bb2f701e5bae0da724068bbce1920458df9cda.zip
rustdoc: change `.src-line-numbers > span` to `.src-line-numbers > a`
This allows people to treat them like real links, such as right-click to
copy URL, and makes the line numbers in a scraped example work at all,
when before this commit was added, they had the clickable pointer cursor
but did not actually do anything when clicked.
Diffstat (limited to 'src/librustdoc/html/render/mod.rs')
-rw-r--r--src/librustdoc/html/render/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 27dea8ec0b3..e09106077f7 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -2888,9 +2888,6 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
         })()
         .unwrap_or(rustc_span::DUMMY_SP);
 
-        // The root path is the inverse of Context::current
-        let root_path = vec!["../"; cx.current.len() - 1].join("");
-
         let mut decoration_info = FxHashMap::default();
         decoration_info.insert("highlight focus", vec![byte_ranges.remove(0)]);
         decoration_info.insert("highlight", byte_ranges);
@@ -2900,9 +2897,13 @@ fn render_call_locations(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Ite
             contents_subset,
             file_span,
             cx,
-            &root_path,
+            &cx.root_path(),
             highlight::DecorationInfo(decoration_info),
-            sources::SourceContext::Embedded { offset: line_min, needs_expansion },
+            sources::SourceContext::Embedded {
+                url: &call_data.url,
+                offset: line_min,
+                needs_expansion,
+            },
         );
         write!(w, "</div></div>");