From 2ff14448863ac1a1dd9533461708e29aae170c2d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:06:31 +0200 Subject: Adding debian version 1.65.0+dfsg1-2. Signed-off-by: Daniel Baumann --- src/librustdoc/html/sources.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/librustdoc/html/sources.rs') diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index d0fd637ba..2e2bee78b 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -11,7 +11,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::LOCAL_CRATE; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_span::edition::Edition; use rustc_span::source_map::FileName; use std::ffi::OsStr; @@ -54,6 +53,7 @@ impl LocalSourcesCollector<'_, '_> { fn add_local_source(&mut self, item: &clean::Item) { let sess = self.tcx.sess; let span = item.span(self.tcx); + let Some(span) = span else { return }; // skip all synthetic "files" if !is_real_and_local(span, sess) { return; @@ -110,6 +110,7 @@ impl DocVisitor for SourceCollector<'_, '_> { let tcx = self.cx.tcx(); let span = item.span(tcx); + let Some(span) = span else { return }; let sess = tcx.sess; // If we're not rendering sources, there's nothing to do. @@ -213,11 +214,10 @@ impl SourceCollector<'_, '_> { print_src( buf, contents, - cx.shared.edition(), file_span, cx, &root_path, - None, + highlight::DecorationInfo::default(), SourceContext::Standalone, ) }, @@ -266,11 +266,10 @@ pub(crate) enum SourceContext { pub(crate) fn print_src( buf: &mut Buffer, s: &str, - edition: Edition, file_span: rustc_span::Span, context: &Context<'_>, root_path: &str, - decoration_info: Option, + decoration_info: highlight::DecorationInfo, source_context: SourceContext, ) { let lines = s.lines().count(); @@ -289,15 +288,14 @@ pub(crate) fn print_src( } } line_numbers.write_str(""); - highlight::render_with_highlighting( + let current_href = &context + .href_from_span(clean::Span::new(file_span), false) + .expect("only local crates should have sources emitted"); + highlight::render_source_with_highlighting( s, buf, - None, - None, - None, - edition, - Some(line_numbers), - Some(highlight::HrefContext { context, file_span, root_path }), + line_numbers, + highlight::HrefContext { context, file_span, root_path, current_href }, decoration_info, ); } -- cgit v1.2.3