From 345077af98bb0efc796536d82e4232aab10671f3 Mon Sep 17 00:00:00 2001 From: Lukas Markeffsky <@> Date: Wed, 25 Sep 2024 22:41:32 +0200 Subject: [PATCH] don't clone `clean::Item` in `TypeImplCollector` --- src/librustdoc/html/render/write_shared.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/render/write_shared.rs b/src/librustdoc/html/render/write_shared.rs index 7db70eb9dd80f..af94b1042c05c 100644 --- a/src/librustdoc/html/render/write_shared.rs +++ b/src/librustdoc/html/render/write_shared.rs @@ -824,9 +824,9 @@ impl Serialize for Implementor { /// this visitor works to reverse that: `aliased_types` is a map /// from target to the aliases that reference it, and each one /// will generate one file. -struct TypeImplCollector<'cx, 'cache> { +struct TypeImplCollector<'cx, 'cache, 'item> { /// Map from DefId-of-aliased-type to its data. - aliased_types: IndexMap>, + aliased_types: IndexMap>, visited_aliases: FxHashSet, cache: &'cache Cache, cx: &'cache mut Context<'cx>, @@ -847,26 +847,26 @@ struct TypeImplCollector<'cx, 'cache> { /// ] /// ) /// ``` -struct AliasedType<'cache> { +struct AliasedType<'cache, 'item> { /// This is used to generate the actual filename of this aliased type. target_fqp: &'cache [Symbol], target_type: ItemType, /// This is the data stored inside the file. /// ItemId is used to deduplicate impls. - impl_: IndexMap>, + impl_: IndexMap>, } /// The `impl_` contains data that's used to figure out if an alias will work, /// and to generate the HTML at the end. /// /// The `type_aliases` list is built up with each type alias that matches. -struct AliasedTypeImpl<'cache> { +struct AliasedTypeImpl<'cache, 'item> { impl_: &'cache Impl, - type_aliases: Vec<(&'cache [Symbol], Item)>, + type_aliases: Vec<(&'cache [Symbol], &'item Item)>, } -impl<'cx, 'cache> DocVisitor<'_> for TypeImplCollector<'cx, 'cache> { - fn visit_item(&mut self, it: &Item) { +impl<'cx, 'cache, 'item> DocVisitor<'item> for TypeImplCollector<'cx, 'cache, 'item> { + fn visit_item(&mut self, it: &'item Item) { self.visit_item_recur(it); let cache = self.cache; let ItemKind::TypeAliasItem(ref t) = it.kind else { return }; @@ -927,7 +927,7 @@ impl<'cx, 'cache> DocVisitor<'_> for TypeImplCollector<'cx, 'cache> { continue; } // This impl was not found in the set of rejected impls - aliased_type_impl.type_aliases.push((&self_fqp[..], it.clone())); + aliased_type_impl.type_aliases.push((&self_fqp[..], it)); } } }