diff --git a/git-branchless-lib/src/core/effects.rs b/git-branchless-lib/src/core/effects.rs index 7f3c0a74b..24e9bee46 100644 --- a/git-branchless-lib/src/core/effects.rs +++ b/git-branchless-lib/src/core/effects.rs @@ -1000,7 +1000,7 @@ impl Drop for ProgressHandle<'_> { } } -impl<'a> ProgressHandle<'a> { +impl ProgressHandle<'_> { /// Notify the progress meter that the current operation has `total` /// discrete units of work, and it's currently `current` units of the way /// through the operation. diff --git a/git-branchless-lib/src/core/node_descriptors.rs b/git-branchless-lib/src/core/node_descriptors.rs index 3c4cb9762..bc3b083ff 100644 --- a/git-branchless-lib/src/core/node_descriptors.rs +++ b/git-branchless-lib/src/core/node_descriptors.rs @@ -44,7 +44,7 @@ pub enum NodeObject<'repo> { }, } -impl<'repo> NodeObject<'repo> { +impl NodeObject<'_> { fn get_oid(&self) -> NonZeroOid { match self { NodeObject::Commit { commit } => commit.get_oid(), @@ -214,7 +214,7 @@ impl<'a> CommitMessageDescriptor<'a> { } } -impl<'a> NodeDescriptor for CommitMessageDescriptor<'a> { +impl NodeDescriptor for CommitMessageDescriptor<'_> { #[instrument] fn describe_node( &mut self, @@ -249,7 +249,7 @@ impl<'a> ObsolescenceExplanationDescriptor<'a> { } } -impl<'a> NodeDescriptor for ObsolescenceExplanationDescriptor<'a> { +impl NodeDescriptor for ObsolescenceExplanationDescriptor<'_> { fn describe_node( &mut self, _glyphs: &Glyphs, @@ -317,7 +317,7 @@ impl<'a> BranchesDescriptor<'a> { } } -impl<'a> NodeDescriptor for BranchesDescriptor<'a> { +impl NodeDescriptor for BranchesDescriptor<'_> { #[instrument] fn describe_node( &mut self, @@ -412,7 +412,7 @@ $", Some(diff_number.to_owned()) } -impl<'a> NodeDescriptor for DifferentialRevisionDescriptor<'a> { +impl NodeDescriptor for DifferentialRevisionDescriptor<'_> { #[instrument] fn describe_node( &mut self, diff --git a/git-branchless-lib/src/core/rewrite/evolve.rs b/git-branchless-lib/src/core/rewrite/evolve.rs index 446a18105..206bea575 100644 --- a/git-branchless-lib/src/core/rewrite/evolve.rs +++ b/git-branchless-lib/src/core/rewrite/evolve.rs @@ -18,11 +18,7 @@ pub fn find_rewrite_target( event_cursor: EventCursor, oid: NonZeroOid, ) -> Option { - let event = event_replayer.get_cursor_commit_latest_event(event_cursor, oid); - let event = match event { - Some(event) => event, - None => return None, - }; + let event = event_replayer.get_cursor_commit_latest_event(event_cursor, oid)?; match event { Event::RewriteEvent { timestamp: _, diff --git a/git-branchless-lib/src/core/task.rs b/git-branchless-lib/src/core/task.rs index b023ca2fd..1f7a0ce6e 100644 --- a/git-branchless-lib/src/core/task.rs +++ b/git-branchless-lib/src/core/task.rs @@ -86,7 +86,7 @@ pub struct ResourceHandle<'pool, R: Resource> { inner: Option, } -impl<'a, R: Resource> Drop for ResourceHandle<'a, R> { +impl Drop for ResourceHandle<'_, R> { fn drop(&mut self) { let mut resources = self .parent @@ -97,7 +97,7 @@ impl<'a, R: Resource> Drop for ResourceHandle<'a, R> { } } -impl<'a, R: Resource> Deref for ResourceHandle<'a, R> { +impl Deref for ResourceHandle<'_, R> { type Target = R::Output; fn deref(&self) -> &Self::Target { diff --git a/git-branchless-lib/src/git/object.rs b/git-branchless-lib/src/git/object.rs index 8f27949d9..adc0c8092 100644 --- a/git-branchless-lib/src/git/object.rs +++ b/git-branchless-lib/src/git/object.rs @@ -319,7 +319,7 @@ pub struct Blob<'repo> { pub(super) inner: git2::Blob<'repo>, } -impl<'repo> Blob<'repo> { +impl Blob<'_> { /// Get the size of the blob in bytes. pub fn size(&self) -> u64 { self.inner.size().try_into().unwrap() diff --git a/git-branchless-lib/src/git/repo.rs b/git-branchless-lib/src/git/repo.rs index 8a6deafab..9725e1037 100644 --- a/git-branchless-lib/src/git/repo.rs +++ b/git-branchless-lib/src/git/repo.rs @@ -449,7 +449,7 @@ pub enum AmendFastOptions<'repo> { }, } -impl<'repo> AmendFastOptions<'repo> { +impl AmendFastOptions<'_> { /// Returns whether there are any paths to be amended. pub fn is_empty(&self) -> bool { match &self { diff --git a/git-branchless-test/src/lib.rs b/git-branchless-test/src/lib.rs index a86d3d89d..add7cd898 100644 --- a/git-branchless-test/src/lib.rs +++ b/git-branchless-test/src/lib.rs @@ -1164,7 +1164,7 @@ struct SearchGraph<'a> { commit_set: CommitSet, } -impl<'a> BasicSourceControlGraph for SearchGraph<'a> { +impl BasicSourceControlGraph for SearchGraph<'_> { type Node = NonZeroOid; type Error = SearchGraphError; diff --git a/scm-bisect/src/search.rs b/scm-bisect/src/search.rs index d9e32ee60..c37e21aaa 100644 --- a/scm-bisect/src/search.rs +++ b/scm-bisect/src/search.rs @@ -265,7 +265,7 @@ impl Search { &'a self, strategy: &'a S, ) -> Result< - LazySolution>, + LazySolution<'a, G::Node, SearchError>, SearchError, > { let success_bounds = self.success_bounds().map_err(SearchError::Graph)?; @@ -284,7 +284,7 @@ impl Search { states: VecDeque>, } - impl<'a, G: Graph, S: Strategy> Iterator for Iter<'a, G, S> { + impl> Iterator for Iter<'_, G, S> { type Item = Result>; fn next(&mut self) -> Option { diff --git a/scm-bisect/src/testing.rs b/scm-bisect/src/testing.rs index a8b0dafc7..20baeccac 100644 --- a/scm-bisect/src/testing.rs +++ b/scm-bisect/src/testing.rs @@ -1,3 +1,5 @@ +//! Testing utilities. + use std::collections::{HashMap, HashSet}; use std::convert::Infallible; @@ -7,8 +9,12 @@ use proptest::prelude::*; use crate::basic::{BasicSourceControlGraph, BasicStrategyKind}; +/// Graph that represents a "stick" of nodes, represented as increasing +/// integers. The node `n` is the immediate parent of `n + 1`. #[derive(Clone, Debug)] pub struct UsizeGraph { + /// The maximum node value for this graph. Valid nodes are in `0..max` (a + /// half-open [`std::ops::Range`]). pub max: usize, } @@ -27,8 +33,10 @@ impl BasicSourceControlGraph for UsizeGraph { } } +/// Directed acyclic graph with nodes `char` and edges `char -> char`. #[derive(Clone, Debug)] pub struct TestGraph { + /// Mapping from parent to children. pub nodes: HashMap>, } @@ -57,6 +65,7 @@ impl BasicSourceControlGraph for TestGraph { } } +/// Select an arbitrary [`BasicStrategyKind`]. pub fn arb_strategy() -> impl ProptestStrategy { prop_oneof![ Just(BasicStrategyKind::Linear), @@ -65,6 +74,7 @@ pub fn arb_strategy() -> impl ProptestStrategy { ] } +/// Create an arbitrary [`TestGraph`] and an arbitrary set of failing nodes. pub fn arb_test_graph_and_nodes() -> impl ProptestStrategy)> { let nodes = prop::collection::hash_set( prop::sample::select(vec!['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']),