Skip to content

Commit

Permalink
don't clone clean::Item in TypeImplCollector
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Sep 25, 2024
1 parent 4facc1c commit 345077a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/librustdoc/html/render/write_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DefId, AliasedType<'cache>>,
aliased_types: IndexMap<DefId, AliasedType<'cache, 'item>>,
visited_aliases: FxHashSet<DefId>,
cache: &'cache Cache,
cx: &'cache mut Context<'cx>,
Expand All @@ -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<ItemId, AliasedTypeImpl<'cache>>,
impl_: IndexMap<ItemId, AliasedTypeImpl<'cache, 'item>>,
}

/// 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 };
Expand Down Expand Up @@ -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));
}
}
}
Expand Down

0 comments on commit 345077a

Please sign in to comment.