From 4e8199b572f2035b7749cba276ece3a26630d23e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:21 +0200 Subject: Adding upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- src/librustdoc/html/sources.rs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/librustdoc/html/sources.rs') diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs index 7ab65bff3..54e296959 100644 --- a/src/librustdoc/html/sources.rs +++ b/src/librustdoc/html/sources.rs @@ -258,7 +258,7 @@ where pub(crate) enum SourceContext { Standalone, - Embedded { offset: usize }, + Embedded { offset: usize, needs_expansion: bool }, } /// Wrapper struct to render the source code of a file. This will do things like @@ -274,28 +274,37 @@ pub(crate) fn print_src( ) { let lines = s.lines().count(); let mut line_numbers = Buffer::empty_from(buf); + let extra; line_numbers.write_str("
");
+    let current_href = &context
+        .href_from_span(clean::Span::new(file_span), false)
+        .expect("only local crates should have sources emitted");
     match source_context {
         SourceContext::Standalone => {
+            extra = None;
             for line in 1..=lines {
-                writeln!(line_numbers, "{0}", line)
+                writeln!(line_numbers, "{line}")
             }
         }
-        SourceContext::Embedded { offset } => {
-            for line in 1..=lines {
-                writeln!(line_numbers, "{0}", line + offset)
+        SourceContext::Embedded { offset, needs_expansion } => {
+            extra = if needs_expansion {
+                Some(r#""#)
+            } else {
+                None
+            };
+            for line_number in 1..=lines {
+                let line = line_number + offset;
+                writeln!(line_numbers, "{line}")
             }
         }
     }
     line_numbers.write_str("
"); - 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, line_numbers, highlight::HrefContext { context, file_span, root_path, current_href }, decoration_info, + extra, ); } -- cgit v1.2.3