diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs
index 62cf2b63f7fd..7b2aee4b4a5d 100644
--- a/src/librustdoc/html/highlight.rs
+++ b/src/librustdoc/html/highlight.rs
@@ -233,7 +233,7 @@ pub(super) fn write_code(
out: &mut impl Write,
src: &str,
href_context: Option>,
- decoration_info: Option,
+ decoration_info: Option<&DecorationInfo>,
) {
// This replace allows to fix how the code source with DOS backline characters is displayed.
let src = src.replace("\r\n", "\n");
@@ -510,12 +510,12 @@ struct Decorations {
}
impl Decorations {
- fn new(info: DecorationInfo) -> Self {
+ fn new(info: &DecorationInfo) -> Self {
// Extract tuples (start, end, kind) into separate sequences of (start, kind) and (end).
let (mut starts, mut ends): (Vec<_>, Vec<_>) = info
.0
- .into_iter()
- .flat_map(|(kind, ranges)| ranges.into_iter().map(move |(lo, hi)| ((lo, kind), hi)))
+ .iter()
+ .flat_map(|(&kind, ranges)| ranges.into_iter().map(move |&(lo, hi)| ((lo, kind), hi)))
.unzip();
// Sort the sequences in document order.
@@ -542,7 +542,7 @@ struct Classifier<'src> {
impl<'src> Classifier<'src> {
/// Takes as argument the source code to HTML-ify, the rust edition to use and the source code
/// file span which will be used later on by the `span_correspondence_map`.
- fn new(src: &str, file_span: Span, decoration_info: Option) -> Classifier<'_> {
+ fn new(src: &'src str, file_span: Span, decoration_info: Option<&DecorationInfo>) -> Self {
let tokens = PeekIter::new(TokenIter { src, cursor: Cursor::new(src) });
let decorations = decoration_info.map(Decorations::new);
Classifier {
diff --git a/src/librustdoc/html/highlight/tests.rs b/src/librustdoc/html/highlight/tests.rs
index fd5275189d66..fccbb98f80ff 100644
--- a/src/librustdoc/html/highlight/tests.rs
+++ b/src/librustdoc/html/highlight/tests.rs
@@ -78,7 +78,7 @@ let a = 4;";
decorations.insert("example2", vec![(22, 32)]);
let mut html = Buffer::new();
- write_code(&mut html, src, None, Some(DecorationInfo(decorations)));
+ write_code(&mut html, src, None, Some(&DecorationInfo(decorations)));
expect_file!["fixtures/decorations.html"].assert_eq(&html.into_inner());
});
}
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs
index 9a9ce31caaa4..8966001c3d6a 100644
--- a/src/librustdoc/html/render/mod.rs
+++ b/src/librustdoc/html/render/mod.rs
@@ -2577,7 +2577,7 @@ fn render_call_locations(mut w: W, cx: &Context<'_>, item: &clean
file_span,
cx,
&cx.root_path(),
- highlight::DecorationInfo(decoration_info),
+ &highlight::DecorationInfo(decoration_info),
sources::SourceContext::Embedded(sources::ScrapedInfo {
needs_expansion,
offset: line_min,
diff --git a/src/librustdoc/html/sources.rs b/src/librustdoc/html/sources.rs
index 9827f97d28df..d13822b7b621 100644
--- a/src/librustdoc/html/sources.rs
+++ b/src/librustdoc/html/sources.rs
@@ -249,7 +249,7 @@ impl SourceCollector<'_, '_> {
file_span,
self.cx,
&root_path,
- highlight::DecorationInfo::default(),
+ &highlight::DecorationInfo::default(),
SourceContext::Standalone { file_path },
)
},
@@ -328,7 +328,7 @@ pub(crate) fn print_src(
file_span: rustc_span::Span,
context: &Context<'_>,
root_path: &str,
- decoration_info: highlight::DecorationInfo,
+ decoration_info: &highlight::DecorationInfo,
source_context: SourceContext<'_>,
) {
let current_href = context