diff --git a/crates/sum_tree/src/sum_tree.rs b/crates/sum_tree/src/sum_tree.rs index 4f9e01ce20..4c5ce39590 100644 --- a/crates/sum_tree/src/sum_tree.rs +++ b/crates/sum_tree/src/sum_tree.rs @@ -41,16 +41,14 @@ pub trait Summary: Clone { fn add_summary(&mut self, summary: &Self, cx: &Self::Context); } -/// This type exists because we can't implement Summary for () without causing -/// type resolution errors -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -pub struct Unit; - -impl Summary for Unit { +/// Catch-all implementation for when you need something that implements [`Summary`] without a specific type. +/// We implement it on a &'static, as that avoids blanket impl collisions with `impl Dimension for T` +/// (as we also need unit type to be a fill-in dimension) +impl Summary for &'static () { type Context = (); fn zero(_: &()) -> Self { - Unit + &() } fn add_summary(&mut self, _: &Self, _: &()) {} diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 4fc6b91abb..e6949f62df 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -62,7 +62,7 @@ use std::{ }, time::{Duration, Instant}, }; -use sum_tree::{Bias, Edit, KeyedItem, SeekTarget, SumTree, Summary, TreeMap, TreeSet, Unit}; +use sum_tree::{Bias, Edit, KeyedItem, SeekTarget, SumTree, Summary, TreeMap, TreeSet}; use text::{LineEnding, Rope}; use util::{ ResultExt, @@ -407,12 +407,12 @@ struct LocalRepositoryEntry { } impl sum_tree::Item for LocalRepositoryEntry { - type Summary = PathSummary; + type Summary = PathSummary<&'static ()>; fn summary(&self, _: &::Context) -> Self::Summary { PathSummary { max_path: self.work_directory.path_key().0, - item_summary: Unit, + item_summary: &(), } } } @@ -425,12 +425,6 @@ impl KeyedItem for LocalRepositoryEntry { } } -//impl LocalRepositoryEntry { -// pub fn repo(&self) -> &Arc { -// &self.repo_ptr -// } -//} - impl Deref for LocalRepositoryEntry { type Target = WorkDirectory; @@ -5417,7 +5411,7 @@ impl<'a> SeekTarget<'a, EntrySummary, TraversalProgress<'a>> for TraversalTarget } } -impl<'a> SeekTarget<'a, PathSummary, TraversalProgress<'a>> for TraversalTarget<'_> { +impl<'a> SeekTarget<'a, PathSummary<&'static ()>, TraversalProgress<'a>> for TraversalTarget<'_> { fn cmp(&self, cursor_location: &TraversalProgress<'a>, _: &()) -> Ordering { self.cmp_progress(cursor_location) }