index: turn CompositeIndex into transparent reference type

This helps to eliminate higher-ranked trait bounds from RevWalkRevset and
RevWalk combinators to be added. Since &CompositeIndex is now a real reference,
it can be passed to functions as index: &T.
This commit is contained in:
Yuya Nishihara 2024-03-10 10:25:27 +09:00
parent c8be8c3edd
commit 243675b793
7 changed files with 78 additions and 77 deletions

View file

@ -20,6 +20,7 @@ use std::iter;
use std::sync::{Arc, Mutex};
use itertools::Itertools;
use ref_cast::{ref_cast_custom, RefCastCustom};
use super::entry::{
IndexEntry, IndexPosition, IndexPositionByGeneration, LocalPosition, SmallIndexPositionsVec,
@ -82,41 +83,41 @@ pub(super) type DynIndexSegment = dyn IndexSegment;
/// a `CompositeIndex` reference.
pub trait AsCompositeIndex {
/// Returns reference wrapper that provides global access to this index.
fn as_composite(&self) -> CompositeIndex<'_>;
fn as_composite(&self) -> &CompositeIndex;
}
impl<T: AsCompositeIndex + ?Sized> AsCompositeIndex for &T {
fn as_composite(&self) -> CompositeIndex<'_> {
fn as_composite(&self) -> &CompositeIndex {
<T as AsCompositeIndex>::as_composite(self)
}
}
impl<T: AsCompositeIndex + ?Sized> AsCompositeIndex for &mut T {
fn as_composite(&self) -> CompositeIndex<'_> {
fn as_composite(&self) -> &CompositeIndex {
<T as AsCompositeIndex>::as_composite(self)
}
}
/// Reference wrapper that provides global access to nested index segments.
#[derive(Clone, Copy)]
pub struct CompositeIndex<'a>(&'a DynIndexSegment);
#[derive(RefCastCustom)]
#[repr(transparent)]
pub struct CompositeIndex(DynIndexSegment);
impl<'a> CompositeIndex<'a> {
pub(super) fn new(segment: &'a DynIndexSegment) -> Self {
CompositeIndex(segment)
}
impl CompositeIndex {
#[ref_cast_custom]
pub(super) const fn new(segment: &DynIndexSegment) -> &Self;
/// Iterates parent and its ancestor readonly index segments.
pub(super) fn ancestor_files_without_local(
&self,
) -> impl Iterator<Item = &'a Arc<ReadonlyIndexSegment>> {
) -> impl Iterator<Item = &Arc<ReadonlyIndexSegment>> {
let parent_file = self.0.parent_file();
iter::successors(parent_file, |file| file.parent_file())
}
/// Iterates self and its ancestor index segments.
pub(super) fn ancestor_index_segments(&self) -> impl Iterator<Item = &'a DynIndexSegment> {
iter::once(self.0).chain(
pub(super) fn ancestor_index_segments(&self) -> impl Iterator<Item = &DynIndexSegment> {
iter::once(&self.0).chain(
self.ancestor_files_without_local()
.map(|file| file.as_ref() as &DynIndexSegment),
)
@ -160,7 +161,7 @@ impl<'a> CompositeIndex<'a> {
}
}
pub fn entry_by_pos(&self, pos: IndexPosition) -> IndexEntry<'a> {
pub fn entry_by_pos(&self, pos: IndexPosition) -> IndexEntry<'_> {
self.ancestor_index_segments()
.find_map(|segment| {
u32::checked_sub(pos.0, segment.num_parent_commits())
@ -169,7 +170,7 @@ impl<'a> CompositeIndex<'a> {
.unwrap()
}
pub fn entry_by_id(&self, commit_id: &CommitId) -> Option<IndexEntry<'a>> {
pub fn entry_by_id(&self, commit_id: &CommitId) -> Option<IndexEntry<'_>> {
self.ancestor_index_segments().find_map(|segment| {
let local_pos = segment.commit_id_to_pos(commit_id)?;
let pos = IndexPosition(local_pos.0 + segment.num_parent_commits());
@ -332,7 +333,7 @@ impl<'a> CompositeIndex<'a> {
self.heads_pos(result)
}
pub(super) fn all_heads(self) -> impl Iterator<Item = CommitId> + 'a {
pub(super) fn all_heads(&self) -> impl Iterator<Item = CommitId> + '_ {
self.all_heads_pos()
.map(move |pos| self.entry_by_pos(pos).commit_id())
}
@ -392,19 +393,19 @@ impl<'a> CompositeIndex<'a> {
&self,
expression: &ResolvedExpression,
store: &Arc<Store>,
) -> Result<Box<dyn Revset + 'a>, RevsetEvaluationError> {
let revset_impl = revset_engine::evaluate(expression, store, *self)?;
) -> Result<Box<dyn Revset + '_>, RevsetEvaluationError> {
let revset_impl = revset_engine::evaluate(expression, store, self)?;
Ok(Box::new(revset_impl))
}
}
impl AsCompositeIndex for CompositeIndex<'_> {
fn as_composite(&self) -> CompositeIndex<'_> {
*self
impl AsCompositeIndex for &CompositeIndex {
fn as_composite(&self) -> &CompositeIndex {
self
}
}
impl Index for CompositeIndex<'_> {
impl Index for &CompositeIndex {
/// Suppose the given `commit_id` exists, returns the minimum prefix length
/// to disambiguate it. The length to be returned is a number of hexadecimal
/// digits.

View file

@ -90,7 +90,7 @@ impl MutableIndexSegment {
}
}
pub(super) fn as_composite(&self) -> CompositeIndex {
pub(super) fn as_composite(&self) -> &CompositeIndex {
CompositeIndex::new(self)
}
@ -467,7 +467,7 @@ impl DefaultMutableIndex {
}
impl AsCompositeIndex for DefaultMutableIndex {
fn as_composite(&self) -> CompositeIndex<'_> {
fn as_composite(&self) -> &CompositeIndex {
self.0.as_composite()
}
}

View file

@ -342,7 +342,7 @@ impl ReadonlyIndexSegment {
}))
}
pub(super) fn as_composite(&self) -> CompositeIndex {
pub(super) fn as_composite(&self) -> &CompositeIndex {
CompositeIndex::new(self)
}
@ -570,7 +570,7 @@ impl DefaultReadonlyIndex {
}
impl AsCompositeIndex for DefaultReadonlyIndex {
fn as_composite(&self) -> CompositeIndex<'_> {
fn as_composite(&self) -> &CompositeIndex {
self.0.as_composite()
}
}

View file

@ -100,7 +100,7 @@ pub(super) trait RevWalkIndex {
fn adjacent_positions(&self, pos: Self::Position) -> Self::AdjacentPositions;
}
impl RevWalkIndex for CompositeIndex<'_> {
impl RevWalkIndex for &CompositeIndex {
type Position = IndexPosition;
type AdjacentPositions = SmallIndexPositionsVec;
@ -118,7 +118,7 @@ pub(super) struct RevWalkDescendantsIndex {
type DescendantIndexPositionsVec = SmallVec<[Reverse<IndexPosition>; 4]>;
impl RevWalkDescendantsIndex {
fn build(index: CompositeIndex, positions: impl IntoIterator<Item = IndexPosition>) -> Self {
fn build(index: &CompositeIndex, positions: impl IntoIterator<Item = IndexPosition>) -> Self {
// For dense set, it's probably cheaper to use `Vec` instead of `HashMap`.
let mut children_map: HashMap<IndexPosition, DescendantIndexPositionsVec> = HashMap::new();
for pos in positions {
@ -242,13 +242,13 @@ impl<P: Ord, T: Ord> RevWalkQueue<P, T> {
#[derive(Clone)]
#[must_use]
pub(super) struct RevWalkBuilder<'a> {
index: CompositeIndex<'a>,
index: &'a CompositeIndex,
wanted: Vec<IndexPosition>,
unwanted: Vec<IndexPosition>,
}
impl<'a> RevWalkBuilder<'a> {
pub fn new(index: CompositeIndex<'a>) -> Self {
pub fn new(index: &'a CompositeIndex) -> Self {
RevWalkBuilder {
index,
wanted: Vec::new(),
@ -383,7 +383,7 @@ impl<'a> RevWalkBuilder<'a> {
}
pub(super) type RevWalkAncestors<'a> =
RevWalkBorrowedIndexIter<CompositeIndex<'a>, RevWalkImpl<IndexPosition>>;
RevWalkBorrowedIndexIter<&'a CompositeIndex, RevWalkImpl<IndexPosition>>;
#[derive(Clone)]
#[must_use]
@ -420,7 +420,7 @@ impl<I: RevWalkIndex + ?Sized> RevWalk<I> for RevWalkImpl<I::Position> {
}
pub(super) type RevWalkAncestorsGenerationRange<'a> =
RevWalkBorrowedIndexIter<CompositeIndex<'a>, RevWalkGenerationRangeImpl<IndexPosition>>;
RevWalkBorrowedIndexIter<&'a CompositeIndex, RevWalkGenerationRangeImpl<IndexPosition>>;
pub(super) type RevWalkDescendantsGenerationRange = RevWalkOwnedIndexIter<
RevWalkDescendantsIndex,
RevWalkGenerationRangeImpl<Reverse<IndexPosition>>,
@ -540,7 +540,7 @@ impl RevWalkItemGenerationRange {
/// Walks descendants from the roots, in order of ascending index position.
pub(super) type RevWalkDescendants<'a> =
RevWalkBorrowedIndexIter<CompositeIndex<'a>, RevWalkDescendantsImpl>;
RevWalkBorrowedIndexIter<&'a CompositeIndex, RevWalkDescendantsImpl>;
#[derive(Clone)]
#[must_use]
@ -561,10 +561,10 @@ impl RevWalkDescendants<'_> {
}
}
impl RevWalk<CompositeIndex<'_>> for RevWalkDescendantsImpl {
impl RevWalk<&CompositeIndex> for RevWalkDescendantsImpl {
type Item = IndexPosition;
fn next(&mut self, index: &CompositeIndex) -> Option<Self::Item> {
fn next(&mut self, index: &&CompositeIndex) -> Option<Self::Item> {
while let Some(candidate_pos) = self.candidate_positions.pop() {
if self.root_positions.contains(&candidate_pos)
|| index
@ -626,7 +626,7 @@ impl AncestorsBitSet {
}
/// Updates set by visiting ancestors until the given `to_visit_pos`.
pub fn visit_until(&mut self, index: CompositeIndex, to_visit_pos: IndexPosition) {
pub fn visit_until(&mut self, index: &CompositeIndex, to_visit_pos: IndexPosition) {
let to_visit_bitset_pos = to_visit_pos.0 / u64::BITS;
if to_visit_bitset_pos >= self.last_visited_bitset_pos {
return;
@ -673,7 +673,7 @@ mod tests {
move || iter.next().unwrap()
}
fn to_positions_vec(index: CompositeIndex<'_>, commit_ids: &[CommitId]) -> Vec<IndexPosition> {
fn to_positions_vec(index: &CompositeIndex, commit_ids: &[CommitId]) -> Vec<IndexPosition> {
commit_ids
.iter()
.map(|id| index.commit_id_to_pos(id).unwrap())

View file

@ -44,14 +44,14 @@ trait ToPredicateFn: fmt::Debug {
/// The predicate function is evaluated in order of `RevsetIterator`.
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a>;
}
impl<T: ToPredicateFn + ?Sized> ToPredicateFn for Box<T> {
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
<T as ToPredicateFn>::to_predicate_fn(self, index)
}
@ -61,12 +61,12 @@ trait InternalRevset: fmt::Debug + ToPredicateFn {
// All revsets currently iterate in order of descending index position
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a>;
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a>;
fn into_predicate<'a>(self: Box<Self>) -> Box<dyn ToPredicateFn + 'a>
@ -77,14 +77,14 @@ trait InternalRevset: fmt::Debug + ToPredicateFn {
impl<T: InternalRevset + ?Sized> InternalRevset for Box<T> {
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
<T as InternalRevset>::entries(self, index)
}
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
<T as InternalRevset>::positions(self, index)
}
@ -174,13 +174,13 @@ impl<I: AsCompositeIndex> Revset for RevsetImpl<I> {
/// Incrementally consumes positions iterator of the revset collecting
/// positions.
struct PositionsAccumulator<'revset, 'index> {
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
inner: RefCell<PositionsAccumulatorInner<'revset>>,
}
impl<'revset, 'index> PositionsAccumulator<'revset, 'index> {
fn new(
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
positions_iter: Box<dyn Iterator<Item = IndexPosition> + 'revset>,
) -> Self {
let inner = RefCell::new(PositionsAccumulatorInner {
@ -252,7 +252,7 @@ impl EagerRevset {
impl InternalRevset for EagerRevset {
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
let entries = self
.positions
@ -263,7 +263,7 @@ impl InternalRevset for EagerRevset {
fn positions<'a, 'index: 'a>(
&'a self,
_index: CompositeIndex<'index>,
_index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
Box::new(self.positions.iter().copied())
}
@ -279,7 +279,7 @@ impl InternalRevset for EagerRevset {
impl ToPredicateFn for EagerRevset {
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
_index: CompositeIndex<'index>,
_index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
predicate_fn_from_positions(self.positions.iter().copied())
}
@ -297,11 +297,11 @@ impl<W> fmt::Debug for RevWalkRevset<W> {
impl<W> InternalRevset for RevWalkRevset<W>
where
W: for<'index> RevWalk<CompositeIndex<'index>, Item = IndexPosition> + Clone,
W: for<'index> RevWalk<&'index CompositeIndex, Item = IndexPosition> + Clone,
{
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
let positions = self.walk.clone().attach(index);
Box::new(positions.map(move |pos| index.entry_by_pos(pos)))
@ -309,7 +309,7 @@ where
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
Box::new(self.walk.clone().attach(index))
}
@ -324,11 +324,11 @@ where
impl<W> ToPredicateFn for RevWalkRevset<W>
where
W: for<'index> RevWalk<CompositeIndex<'index>, Item = IndexPosition> + Clone,
W: for<'index> RevWalk<&'index CompositeIndex, Item = IndexPosition> + Clone,
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let positions = self.walk.clone().attach(index);
predicate_fn_from_positions(positions)
@ -360,7 +360,7 @@ where
{
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
let p = self.predicate.to_predicate_fn(index);
Box::new(self.candidates.entries(index).filter(p))
@ -368,7 +368,7 @@ where
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
Box::new(self.entries(index).map(|entry| entry.position()))
}
@ -388,7 +388,7 @@ where
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let mut p1 = self.candidates.to_predicate_fn(index);
let mut p2 = self.predicate.to_predicate_fn(index);
@ -402,7 +402,7 @@ struct NotInPredicate<S>(S);
impl<S: ToPredicateFn> ToPredicateFn for NotInPredicate<S> {
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let mut p = self.0.to_predicate_fn(index);
Box::new(move |entry| !p(entry))
@ -422,7 +422,7 @@ where
{
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
Box::new(union_by(
self.set1.entries(index),
@ -433,7 +433,7 @@ where
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
Box::new(union_by(
self.set1.positions(index),
@ -457,7 +457,7 @@ where
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let mut p1 = self.set1.to_predicate_fn(index);
let mut p2 = self.set2.to_predicate_fn(index);
@ -528,7 +528,7 @@ where
{
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
Box::new(intersection_by(
self.set1.entries(index),
@ -539,7 +539,7 @@ where
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
Box::new(intersection_by(
self.set1.positions(index),
@ -563,7 +563,7 @@ where
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let mut p1 = self.set1.to_predicate_fn(index);
let mut p2 = self.set2.to_predicate_fn(index);
@ -646,7 +646,7 @@ where
{
fn entries<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexEntry<'index>> + 'a> {
Box::new(difference_by(
self.set1.entries(index),
@ -657,7 +657,7 @@ where
fn positions<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn Iterator<Item = IndexPosition> + 'a> {
Box::new(difference_by(
self.set1.positions(index),
@ -681,7 +681,7 @@ where
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let mut p1 = self.set1.to_predicate_fn(index);
let mut p2 = self.set2.to_predicate_fn(index);
@ -764,7 +764,7 @@ pub fn evaluate<I: AsCompositeIndex>(
struct EvaluationContext<'index> {
store: Arc<Store>,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
}
fn to_u32_generation_range(range: &Range<u64>) -> Result<Range<u32>, RevsetEvaluationError> {
@ -1024,11 +1024,11 @@ impl<F> fmt::Debug for PurePredicateFn<F> {
impl<F> ToPredicateFn for PurePredicateFn<F>
where
F: Fn(CompositeIndex<'_>, &IndexEntry<'_>) -> bool,
F: Fn(&CompositeIndex, &IndexEntry<'_>) -> bool,
{
fn to_predicate_fn<'a, 'index: 'a>(
&'a self,
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
) -> Box<dyn FnMut(&IndexEntry<'_>) -> bool + 'a> {
let f = &self.0;
Box::new(move |entry| f(index, entry))
@ -1037,13 +1037,13 @@ where
fn as_pure_predicate_fn<F>(f: F) -> PurePredicateFn<F>
where
F: Fn(CompositeIndex<'_>, &IndexEntry<'_>) -> bool,
F: Fn(&CompositeIndex, &IndexEntry<'_>) -> bool,
{
PurePredicateFn(f)
}
fn box_pure_predicate_fn<'a>(
f: impl Fn(CompositeIndex<'_>, &IndexEntry<'_>) -> bool + 'a,
f: impl Fn(&CompositeIndex, &IndexEntry<'_>) -> bool + 'a,
) -> Box<dyn ToPredicateFn + 'a> {
Box::new(PurePredicateFn(f))
}
@ -1104,7 +1104,7 @@ fn build_predicate_fn(
fn has_diff_from_parent(
store: &Arc<Store>,
index: CompositeIndex<'_>,
index: &CompositeIndex,
entry: &IndexEntry<'_>,
matcher: &dyn Matcher,
) -> bool {

View file

@ -46,7 +46,7 @@ impl IndexGraphEdge {
IndexGraphEdge { target, edge_type }
}
fn to_revset_edge(self, index: CompositeIndex<'_>) -> RevsetGraphEdge {
fn to_revset_edge(self, index: &CompositeIndex) -> RevsetGraphEdge {
RevsetGraphEdge {
target: index.entry_by_pos(self.target).commit_id(),
edge_type: self.edge_type,
@ -121,7 +121,7 @@ impl IndexGraphEdge {
/// could lead to "D", but that would require extra book-keeping to remember for
/// later that the edges from "f" and "H" are only partially computed.
pub struct RevsetGraphIterator<'revset, 'index> {
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
input_set_iter: Box<dyn Iterator<Item = IndexEntry<'index>> + 'revset>,
/// Commits in the input set we had to take out of the iterator while
/// walking external edges. Does not necessarily include the commit
@ -137,7 +137,7 @@ pub struct RevsetGraphIterator<'revset, 'index> {
impl<'revset, 'index> RevsetGraphIterator<'revset, 'index> {
pub fn new(
index: CompositeIndex<'index>,
index: &'index CompositeIndex,
input_set_iter: Box<dyn Iterator<Item = IndexEntry<'index>> + 'revset>,
) -> RevsetGraphIterator<'revset, 'index> {
RevsetGraphIterator {

View file

@ -46,7 +46,7 @@ fn child_commit<'repo>(
}
// Helper just to reduce line wrapping
fn generation_number(index: CompositeIndex, commit_id: &CommitId) -> u32 {
fn generation_number(index: &CompositeIndex, commit_id: &CommitId) -> u32 {
index.entry_by_id(commit_id).unwrap().generation_number()
}
@ -510,7 +510,7 @@ fn create_n_commits(
tx.commit("test")
}
fn as_readonly_composite(repo: &Arc<ReadonlyRepo>) -> CompositeIndex<'_> {
fn as_readonly_composite(repo: &Arc<ReadonlyRepo>) -> &CompositeIndex {
repo.readonly_index()
.as_any()
.downcast_ref::<DefaultReadonlyIndex>()
@ -518,7 +518,7 @@ fn as_readonly_composite(repo: &Arc<ReadonlyRepo>) -> CompositeIndex<'_> {
.as_composite()
}
fn as_mutable_composite(repo: &MutableRepo) -> CompositeIndex<'_> {
fn as_mutable_composite(repo: &MutableRepo) -> &CompositeIndex {
repo.mutable_index()
.as_any()
.downcast_ref::<DefaultMutableIndex>()