cleanup: remove redundant + use<'_> after migrating to 2024 edition

AliasFunctionOverloads::arities() doesn't need to capture &self, but it's not
important to describe the lifetime precisely here.
This commit is contained in:
Yuya Nishihara 2025-10-22 23:22:34 +09:00
parent 0034daa9ac
commit 5f40f62494
17 changed files with 65 additions and 84 deletions

View file

@ -1116,10 +1116,10 @@ impl JjBuilder {
/// multiple times, the parsing will pick any of the available ones, while the
/// actual execution of the command would fail.
mod parse {
pub(super) fn parse_flag<'a, I: Iterator<Item = String>>(
candidates: &'a [&str],
mut args: I,
) -> impl Iterator<Item = String> + use<'a, I> {
pub(super) fn parse_flag(
candidates: &[&str],
mut args: impl Iterator<Item = String>,
) -> impl Iterator<Item = String> {
std::iter::from_fn(move || {
for arg in args.by_ref() {
// -r REV syntax

View file

@ -762,7 +762,7 @@ fn duplicate_child_stdin(stdin: &ChildStdin) -> io::Result<std::os::windows::io:
stdin.as_handle().try_clone_to_owned()
}
fn format_error_with_sources(err: &dyn error::Error) -> impl fmt::Display + use<'_> {
fn format_error_with_sources(err: &dyn error::Error) -> impl fmt::Display {
iter::successors(Some(err), |&err| err.source()).format(": ")
}

View file

@ -100,7 +100,7 @@ impl Commit {
&self.data.parents
}
pub fn parents(&self) -> impl Iterator<Item = BackendResult<Self>> + use<'_> {
pub fn parents(&self) -> impl Iterator<Item = BackendResult<Self>> {
self.data.parents.iter().map(|id| self.store.get_commit(id))
}

View file

@ -687,10 +687,10 @@ pub struct MaterializedTreeDiffEntry {
pub values: BackendResult<(MaterializedTreeValue, MaterializedTreeValue)>,
}
pub fn materialized_diff_stream<'a>(
store: &'a Store,
tree_diff: BoxStream<'a, CopiesTreeDiffEntry>,
) -> impl Stream<Item = MaterializedTreeDiffEntry> + use<'a> {
pub fn materialized_diff_stream(
store: &Store,
tree_diff: BoxStream<'_, CopiesTreeDiffEntry>,
) -> impl Stream<Item = MaterializedTreeDiffEntry> {
tree_diff
.map(async |CopiesTreeDiffEntry { path, values }| match values {
Err(err) => MaterializedTreeDiffEntry {

View file

@ -367,7 +367,7 @@ impl CompositeCommitIndex {
self.heads_pos(result)
}
pub(super) fn all_heads(&self) -> impl Iterator<Item = CommitId> + use<'_> {
pub(super) fn all_heads(&self) -> impl Iterator<Item = CommitId> {
self.all_heads_pos()
.map(move |pos| self.entry_by_pos(pos).commit_id())
}

View file

@ -457,7 +457,7 @@ impl ReadonlyCommitIndexSegment {
fn overflow_changes_from(
&self,
overflow_pos: u32,
) -> impl Iterator<Item = LocalCommitPosition> + use<'_> {
) -> impl Iterator<Item = LocalCommitPosition> {
let table = &self.data[self.change_overflow_base..];
let offset = (overflow_pos as usize) * 4;
let (chunks, _remainder) = table[offset..].as_chunks();

View file

@ -121,8 +121,7 @@ impl<I: AsCompositeIndex + Clone> RevsetImpl<I> {
fn positions(
&self,
) -> impl Iterator<Item = Result<GlobalCommitPosition, RevsetEvaluationError>> + use<'_, I>
{
) -> impl Iterator<Item = Result<GlobalCommitPosition, RevsetEvaluationError>> {
self.inner.positions().attach(self.index.as_composite())
}
@ -1420,10 +1419,7 @@ fn diff_match_lines(
}
}
fn match_lines<'a, 'b>(
text: &'a [u8],
pattern: &'b StringPattern,
) -> impl Iterator<Item = &'a [u8]> + use<'a, 'b> {
fn match_lines<'a>(text: &'a [u8], pattern: &StringPattern) -> impl Iterator<Item = &'a [u8]> {
// The pattern is matched line by line so that it can be anchored to line
// start/end. For example, exact:"" will match blank lines.
text.split_inclusive(|b| *b == b'\n').filter(|line| {

View file

@ -76,11 +76,11 @@ pub fn find_nonword_ranges(text: &[u8]) -> Vec<Range<usize>> {
.collect()
}
fn bytes_ignore_all_whitespace(text: &[u8]) -> impl Iterator<Item = u8> + use<'_> {
fn bytes_ignore_all_whitespace(text: &[u8]) -> impl Iterator<Item = u8> {
text.iter().copied().filter(|b| !b.is_ascii_whitespace())
}
fn bytes_ignore_whitespace_amount(text: &[u8]) -> impl Iterator<Item = u8> + use<'_> {
fn bytes_ignore_whitespace_amount(text: &[u8]) -> impl Iterator<Item = u8> {
let mut prev_was_space = false;
text.iter().filter_map(move |&b| {
let was_space = prev_was_space;
@ -295,8 +295,7 @@ impl<'input> LocalDiffSource<'input, '_> {
fn hashed_words(
&self,
) -> impl DoubleEndedIterator<Item = HashedWord<'input>> + ExactSizeIterator + use<'_, 'input>
{
) -> impl DoubleEndedIterator<Item = HashedWord<'input>> + ExactSizeIterator {
iter::zip(self.ranges, self.hashes).map(|(range, &hash)| {
let text = &self.text[range.clone()];
HashedWord { hash, text }
@ -780,10 +779,7 @@ impl<'input> ContentDiff<'input> {
}
/// Returns contents at the unchanged `range`.
fn hunk_at<'a, 'b>(
&'a self,
range: &'b UnchangedRange,
) -> impl Iterator<Item = &'input BStr> + use<'a, 'b, 'input> {
fn hunk_at(&self, range: &UnchangedRange) -> impl Iterator<Item = &'input BStr> {
itertools::chain(
iter::once(&self.base_input[range.base.clone()]),
iter::zip(&self.other_inputs, &range.others).map(|(input, r)| &input[r.clone()]),
@ -791,11 +787,11 @@ impl<'input> ContentDiff<'input> {
}
/// Returns contents between the `previous` ends and the `current` starts.
fn hunk_between<'a, 'b>(
&'a self,
previous: &'b UnchangedRange,
current: &'b UnchangedRange,
) -> impl Iterator<Item = &'input BStr> + use<'a, 'b, 'input> {
fn hunk_between(
&self,
previous: &UnchangedRange,
current: &UnchangedRange,
) -> impl Iterator<Item = &'input BStr> {
itertools::chain(
iter::once(&self.base_input[previous.base.end..current.base.start]),
itertools::izip!(&self.other_inputs, &previous.others, &current.others)

View file

@ -604,10 +604,7 @@ struct AliasFunctionOverloads<'a, V> {
}
impl<'a, V> AliasFunctionOverloads<'a, V> {
// TODO: Perhaps, V doesn't have to be captured, but "currently, all type
// parameters are required to be mentioned in the precise captures list" as
// of rustc 1.85.0.
fn arities(&self) -> impl DoubleEndedIterator<Item = usize> + ExactSizeIterator + use<'a, V> {
fn arities(&self) -> impl DoubleEndedIterator<Item = usize> + ExactSizeIterator {
self.overloads.iter().map(|(params, _)| params.len())
}

View file

@ -58,7 +58,7 @@ impl CommitEvolutionEntry {
}
/// Predecessor commit objects of this commit.
pub fn predecessors(&self) -> impl ExactSizeIterator<Item = BackendResult<Commit>> + use<'_> {
pub fn predecessors(&self) -> impl ExactSizeIterator<Item = BackendResult<Commit>> {
let store = self.commit.store();
self.predecessor_ids().iter().map(|id| store.get_commit(id))
}

View file

@ -464,11 +464,11 @@ fn collect_resolved<'input>(hunks: impl IntoIterator<Item = MergeHunk<'input>>)
}
/// Iterator that attempts to resolve trivial merge conflict for each hunk.
fn resolve_diff_hunks<'a, 'input>(
diff: &'a ContentDiff<'input>,
fn resolve_diff_hunks<'input>(
diff: &ContentDiff<'input>,
num_diffs: usize,
same_change: SameChange,
) -> impl Iterator<Item = Merge<&'input BStr>> + use<'a, 'input> {
) -> impl Iterator<Item = Merge<&'input BStr>> {
diff.hunks().map(move |diff_hunk| match diff_hunk.kind {
DiffHunkKind::Matching => {
debug_assert!(diff_hunk.contents.iter().all_equal());

View file

@ -484,10 +484,7 @@ impl<V> RepoPathTree<V> {
fn walk_to<'a, 'b>(
&'a self,
dir: &'b RepoPath,
// TODO: V doesn't have to be captured, but "currently, all type
// parameters are required to be mentioned in the precise captures list"
// as of rustc 1.85.0.
) -> impl Iterator<Item = (&'a Self, &'b RepoPath)> + use<'a, 'b, V> {
) -> impl Iterator<Item = (&'a Self, &'b RepoPath)> {
iter::successors(Some((self, dir)), |(sub, dir)| {
let mut components = dir.components();
let name = components.next()?;

View file

@ -106,7 +106,7 @@ impl Operation {
&self.data.parents
}
pub fn parents(&self) -> impl ExactSizeIterator<Item = OpStoreResult<Self>> + use<'_> {
pub fn parents(&self) -> impl ExactSizeIterator<Item = OpStoreResult<Self>> {
let op_store = &self.op_store;
self.data.parents.iter().map(|parent_id| {
let data = op_store.read_operation(parent_id).block_on()?;

View file

@ -2517,7 +2517,7 @@ fn to_resolved_ref(
fn all_formatted_bookmark_symbols(
repo: &dyn Repo,
include_synced_remotes: bool,
) -> impl Iterator<Item = String> + use<'_> {
) -> impl Iterator<Item = String> {
let view = repo.view();
view.bookmarks().flat_map(move |(name, bookmark_target)| {
let local_target = bookmark_target.local_target;

View file

@ -325,10 +325,10 @@ impl StringPattern {
/// Iterates entries of the given `map` whose string keys match this
/// pattern.
pub fn filter_btree_map<'a, 'b, K: Borrow<str> + Ord, V>(
&'b self,
pub fn filter_btree_map<'a, K: Borrow<str> + Ord, V>(
&self,
map: &'a BTreeMap<K, V>,
) -> impl Iterator<Item = (&'a K, &'a V)> + use<'a, 'b, K, V> {
) -> impl Iterator<Item = (&'a K, &'a V)> {
self.filter_btree_map_with(map, |key| key, |key| key)
}
@ -337,10 +337,10 @@ impl StringPattern {
///
/// The borrowed key type is constrained by the `Deref::Target`. It must be
/// convertible to/from `str`.
pub fn filter_btree_map_as_deref<'a, 'b, K, V>(
&'b self,
pub fn filter_btree_map_as_deref<'a, K, V>(
&self,
map: &'a BTreeMap<K, V>,
) -> impl Iterator<Item = (&'a K, &'a V)> + use<'a, 'b, K, V>
) -> impl Iterator<Item = (&'a K, &'a V)>
where
K: Borrow<K::Target> + Deref + Ord,
K::Target: AsRef<str> + Ord,
@ -349,20 +349,15 @@ impl StringPattern {
self.filter_btree_map_with(map, AsRef::as_ref, AsRef::as_ref)
}
fn filter_btree_map_with<'a, 'b, K, Q, V, FromKey, ToKey>(
&'b self,
fn filter_btree_map_with<'a, K, Q, V>(
&self,
map: &'a BTreeMap<K, V>,
from_key: FromKey,
to_key: ToKey,
// TODO: Q, FromKey, and ToKey don't have to be captured, but
// "currently, all type parameters are required to be mentioned in the
// precise captures list" as of rustc 1.85.0.
) -> impl Iterator<Item = (&'a K, &'a V)> + use<'a, 'b, K, Q, V, FromKey, ToKey>
from_key: impl Fn(&Q) -> &str,
to_key: impl Fn(&str) -> &Q,
) -> impl Iterator<Item = (&'a K, &'a V)>
where
K: Borrow<Q> + Ord,
Q: Ord + ?Sized,
FromKey: Fn(&Q) -> &str,
ToKey: Fn(&str) -> &Q,
{
if let Some(key) = self.as_exact() {
Either::Left(map.get_key_value(to_key(key)).into_iter())

View file

@ -146,20 +146,20 @@ impl View {
/// Iterates local bookmarks `(name, target)` in lexicographical order where
/// the target adds `commit_id`.
pub fn local_bookmarks_for_commit<'a, 'b>(
&'a self,
commit_id: &'b CommitId,
) -> impl Iterator<Item = (&'a RefName, &'a RefTarget)> + use<'a, 'b> {
pub fn local_bookmarks_for_commit(
&self,
commit_id: &CommitId,
) -> impl Iterator<Item = (&RefName, &RefTarget)> {
self.local_bookmarks()
.filter(|(_, target)| target.added_ids().contains(commit_id))
}
/// Iterates local bookmark `(name, target)`s matching the given pattern.
/// Entries are sorted by `name`.
pub fn local_bookmarks_matching<'a, 'b>(
&'a self,
pattern: &'b StringPattern,
) -> impl Iterator<Item = (&'a RefName, &'a RefTarget)> + use<'a, 'b> {
pub fn local_bookmarks_matching(
&self,
pattern: &StringPattern,
) -> impl Iterator<Item = (&RefName, &RefTarget)> {
pattern
.filter_btree_map_as_deref(&self.data.local_bookmarks)
.map(|(name, target)| (name.as_ref(), target))
@ -215,11 +215,11 @@ impl View {
/// specified remote that match the given pattern.
///
/// Entries are sorted by `symbol`, which is `(name, remote)`.
pub fn remote_bookmarks_matching<'a, 'b>(
&'a self,
bookmark_pattern: &'b StringPattern,
remote_pattern: &'b StringPattern,
) -> impl Iterator<Item = (RemoteRefSymbol<'a>, &'a RemoteRef)> + use<'a, 'b> {
pub fn remote_bookmarks_matching(
&self,
bookmark_pattern: &StringPattern,
remote_pattern: &StringPattern,
) -> impl Iterator<Item = (RemoteRefSymbol<'_>, &RemoteRef)> {
// Use kmerge instead of flat_map for consistency with all_remote_bookmarks().
remote_pattern
.filter_btree_map_as_deref(&self.data.remote_views)
@ -362,10 +362,10 @@ impl View {
/// Iterates local tag `(name, target)`s matching the given pattern. Entries
/// are sorted by `name`.
pub fn local_tags_matching<'a, 'b>(
&'a self,
pattern: &'b StringPattern,
) -> impl Iterator<Item = (&'a RefName, &'a RefTarget)> + use<'a, 'b> {
pub fn local_tags_matching(
&self,
pattern: &StringPattern,
) -> impl Iterator<Item = (&RefName, &RefTarget)> {
pattern
.filter_btree_map_as_deref(&self.data.local_tags)
.map(|(name, target)| (name.as_ref(), target))
@ -416,11 +416,11 @@ impl View {
/// specified remote that match the given pattern.
///
/// Entries are sorted by `symbol`, which is `(name, remote)`.
pub fn remote_tags_matching<'a, 'b>(
&'a self,
tag_pattern: &'b StringPattern,
remote_pattern: &'b StringPattern,
) -> impl Iterator<Item = (RemoteRefSymbol<'a>, &'a RemoteRef)> + use<'a, 'b> {
pub fn remote_tags_matching(
&self,
tag_pattern: &StringPattern,
remote_pattern: &StringPattern,
) -> impl Iterator<Item = (RemoteRefSymbol<'_>, &RemoteRef)> {
// Use kmerge instead of flat_map for consistency with all_remote_tags().
remote_pattern
.filter_btree_map_as_deref(&self.data.remote_views)

View file

@ -37,7 +37,7 @@ use testutils::repo_path;
fn create_commit_fn(
mut_repo: &mut MutableRepo,
) -> impl FnMut(&str, &[&CommitId], MergedTreeId) -> Commit + use<'_> {
) -> impl FnMut(&str, &[&CommitId], MergedTreeId) -> Commit {
// stabilize commit IDs for ease of debugging
let signature = Signature {
name: "Some One".to_owned(),