Skip to content

Commit 9e04685

Browse files
committed
thanks clippy
1 parent dd7f3bf commit 9e04685

File tree

65 files changed

+144
-110
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+144
-110
lines changed

Diff for: clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.60.0"
1+
msrv = "1.64.0"

Diff for: git-attributes/src/match_group.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Pattern for Attributes {
7878
Value::MacroAttributes(into_owned_assignments(assignments).ok()?),
7979
),
8080
crate::parse::Kind::Pattern(p) => (
81-
(!p.is_negative()).then(|| p)?,
81+
(!p.is_negative()).then_some(p)?,
8282
Value::Assignments(into_owned_assignments(assignments).ok()?),
8383
),
8484
};
@@ -278,7 +278,7 @@ where
278278
}| {
279279
pattern
280280
.matches_repo_relative_path(relative_path, basename_start_pos, is_dir, case)
281-
.then(|| Match {
281+
.then_some(Match {
282282
pattern,
283283
value,
284284
source: self.source.as_deref(),
@@ -307,7 +307,7 @@ where
307307
.find_map(|(idx, pm)| {
308308
pm.pattern
309309
.matches_repo_relative_path(relative_path, basename_start_pos, is_dir, case)
310-
.then(|| idx)
310+
.then_some(idx)
311311
})
312312
}
313313

@@ -321,7 +321,7 @@ where
321321
relative_path.strip_prefix(base.as_slice())?.as_bstr(),
322322
basename_pos.and_then(|pos| {
323323
let pos = pos - base.len();
324-
(pos != 0).then(|| pos)
324+
(pos != 0).then_some(pos)
325325
}),
326326
),
327327
None => (relative_path, basename_pos),

Diff for: git-config/src/file/access/mutate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ impl<'event> File<'event> {
349349
lhs.extend(rhs);
350350
}
351351
let our_last_section_before_append =
352-
insert_after.or_else(|| (self.section_id_counter != 0).then(|| SectionId(self.section_id_counter - 1)));
352+
insert_after.or_else(|| (self.section_id_counter != 0).then_some(SectionId(self.section_id_counter - 1)));
353353

354354
for id in std::mem::take(&mut other.section_order) {
355355
let section = other.sections.remove(&id).expect("present");

Diff for: git-config/src/file/access/read_only.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'event> File<'event> {
166166
let sections = &self.sections;
167167
move |id| {
168168
let s = &sections[&id];
169-
filter(s.meta()).then(|| s)
169+
filter(s.meta()).then_some(s)
170170
}
171171
}))
172172
}
@@ -258,7 +258,7 @@ impl<'event> File<'event> {
258258
.sections
259259
.get(&id)
260260
.expect("section doesn't have id from from lookup");
261-
filter(s.meta()).then(|| s)
261+
filter(s.meta()).then_some(s)
262262
})
263263
})
264264
}

Diff for: git-config/src/file/includes/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fn onbranch_matches(
189189
branch_name,
190190
git_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL,
191191
)
192-
.then(|| ())
192+
.then_some(())
193193
}
194194

195195
fn gitdir_matches(

Diff for: git-config/src/file/init/comfort.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl File<'static> {
3131
.filter_map(|source| {
3232
let path = source
3333
.storage_location(&mut |name| std::env::var_os(name))
34-
.and_then(|p| p.is_file().then(|| p))
34+
.and_then(|p| p.is_file().then_some(p))
3535
.map(|p| p.into_owned());
3636

3737
Metadata {

Diff for: git-config/src/file/mutable/section.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a, 'event> SectionMut<'a, 'event> {
7171
if !bytes.peek().map_or(true, |b| b.is_ascii_whitespace()) {
7272
c.insert(0, b' ');
7373
}
74-
c.extend(bytes.map(|b| (*b == b'\n').then(|| b' ').unwrap_or(*b)));
74+
c.extend(bytes.map(|b| if *b == b'\n' { b' ' } else { *b }));
7575
c.into()
7676
}),
7777
}));

Diff for: git-config/src/file/section/body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'event> Body<'event> {
153153
// is included in the range
154154
let value_range = value_range.start..value_range.end + 1;
155155
let key_range = key_start..value_range.end;
156-
(key_range, (value_range.start != key_start + 1).then(|| value_range))
156+
(key_range, (value_range.start != key_start + 1).then_some(value_range))
157157
})
158158
}
159159
}

Diff for: git-config/src/file/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'event> File<'event> {
6161
section_order
6262
.iter()
6363
.enumerate()
64-
.find_map(|(idx, id)| (*id == section_id).then(|| idx))
64+
.find_map(|(idx, id)| (*id == section_id).then_some(idx))
6565
.expect("before-section exists")
6666
}
6767
};

Diff for: git-config/src/file/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub(crate) fn ends_with_newline(e: &[crate::parse::Event<'_>], nl: impl AsRef<[u
6363
e.iter()
6464
.rev()
6565
.take_while(|e| e.to_bstr_lossy().iter().all(|b| b.is_ascii_whitespace()))
66-
.find_map(|e| e.to_bstr_lossy().contains_str(nl.as_ref()).then(|| true))
66+
.find_map(|e| e.to_bstr_lossy().contains_str(nl.as_ref()).then_some(true))
6767
.unwrap_or(false)
6868
}
6969

Diff for: git-config/src/parse/nom/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ fn value_impl<'a>(i: &'a [u8], dispatch: &mut impl FnMut(Event<'a>)) -> IResult<
400400
.iter()
401401
.enumerate()
402402
.rev()
403-
.find_map(|(idx, b)| (!b.is_ascii_whitespace()).then(|| idx + 1))
403+
.find_map(|(idx, b)| (!b.is_ascii_whitespace()).then_some(idx + 1))
404404
.unwrap_or(0);
405405
(
406406
&i[value_end_no_trailing_whitespace..],

Diff for: git-config/src/parse/section/header.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ pub fn is_valid_subsection(name: &BStr) -> bool {
4848

4949
fn validated_subsection(name: Cow<'_, BStr>) -> Result<Cow<'_, BStr>, Error> {
5050
is_valid_subsection(name.as_ref())
51-
.then(|| name)
51+
.then_some(name)
5252
.ok_or(Error::InvalidSubSection)
5353
}
5454

5555
fn validated_name(name: Cow<'_, BStr>) -> Result<Cow<'_, BStr>, Error> {
5656
name.iter()
5757
.all(|b| b.is_ascii_alphanumeric() || *b == b'-')
58-
.then(|| name)
58+
.then_some(name)
5959
.ok_or(Error::InvalidName)
6060
}
6161

Diff for: git-discover/src/upwards/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) mod function {
6060

6161
let filter_by_trust = |x: &Path| -> Result<Option<Trust>, Error> {
6262
let trust = Trust::from_path_ownership(x).map_err(|err| Error::CheckTrust { path: x.into(), err })?;
63-
Ok((trust >= required_trust).then(|| (trust)))
63+
Ok((trust >= required_trust).then_some(trust))
6464
};
6565

6666
let max_height = if !ceiling_dirs.is_empty() {

Diff for: git-features/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub mod iter {
5858
break;
5959
}
6060
}
61-
(!res.is_empty()).then(|| res)
61+
(!res.is_empty()).then_some(res)
6262
}
6363
}
6464
}

Diff for: git-features/src/parallel/in_parallel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ where
165165
let mut state = new_thread_state(thread_id);
166166
while let Ok(input_index) =
167167
index.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| {
168-
(x < input_len).then(|| x + 1)
168+
(x < input_len).then_some(x + 1)
169169
})
170170
{
171171
if stop_everything.load(Ordering::Relaxed) {

Diff for: git-glob/src/wildmatch.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ pub(crate) mod function {
7272
}
7373
}
7474
STAR => {
75-
let mut match_slash = mode
76-
.contains(Mode::NO_MATCH_SLASH_LITERAL)
77-
.then(|| false)
78-
.unwrap_or(true);
75+
let mut match_slash = !mode.contains(Mode::NO_MATCH_SLASH_LITERAL);
7976
match p.next() {
8077
Some((next_p_idx, next_p_ch)) => {
8178
let next;

Diff for: git-index/src/extension/index_entry_offset_table.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ pub fn decode(data: &[u8]) -> Option<Vec<Offset>> {
3838

3939
pub fn find(extensions: &[u8], object_hash: git_hash::Kind) -> Option<Vec<Offset>> {
4040
extension::Iter::new_without_checksum(extensions, object_hash)?
41-
.find_map(|(sig, ext_data)| (sig == SIGNATURE).then(|| ext_data))
41+
.find_map(|(sig, ext_data)| (sig == SIGNATURE).then_some(ext_data))
4242
.and_then(decode)
4343
}

Diff for: git-index/src/extension/tree/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl Tree {
119119
}
120120

121121
let mut buf = Vec::new();
122-
let declared_entries = verify_recursive(self.id, &self.children, use_find.then(|| &mut buf), &mut find)?;
122+
let declared_entries = verify_recursive(self.id, &self.children, use_find.then_some(&mut buf), &mut find)?;
123123
if let Some((actual, num_entries)) = declared_entries.zip(self.num_entries) {
124124
if actual > num_entries {
125125
return Err(Error::EntriesCount {

Diff for: git-index/src/extension/untracked_cache.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ pub fn decode(data: &[u8], object_hash: git_hash::Kind) -> Option<UntrackedCache
5858

5959
let mut res = UntrackedCache {
6060
identifier: identifier.into(),
61-
info_exclude: (!info_exclude.id.is_null()).then(|| info_exclude),
62-
excludes_file: (!excludes_file.id.is_null()).then(|| excludes_file),
61+
info_exclude: (!info_exclude.id.is_null()).then_some(info_exclude),
62+
excludes_file: (!excludes_file.id.is_null()).then_some(excludes_file),
6363
exclude_filename_per_dir: exclude_filename_per_dir.into(),
6464
dir_flags,
6565
directories: Vec::new(),
6666
};
6767
if num_directory_blocks == 0 {
68-
return data.is_empty().then(|| res);
68+
return data.is_empty().then_some(res);
6969
}
7070

7171
let num_directory_blocks = num_directory_blocks.try_into().ok()?;

Diff for: git-index/src/file/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ impl File {
3333
&mut git_features::progress::Discard,
3434
&should_interrupt,
3535
)?;
36-
(actual == checksum).then(|| ()).ok_or(Error::ChecksumMismatch {
36+
(actual == checksum).then_some(()).ok_or(Error::ChecksumMismatch {
3737
actual,
3838
expected: checksum,
3939
})

Diff for: git-index/src/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl State {
132132
fn detect_required_version(&self) -> Version {
133133
self.entries
134134
.iter()
135-
.find_map(|e| e.flags.contains(entry::Flags::EXTENDED).then(|| Version::V3))
135+
.find_map(|e| e.flags.contains(entry::Flags::EXTENDED).then_some(Version::V3))
136136
.unwrap_or(Version::V2)
137137
}
138138
}

Diff for: git-mailmap/src/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ fn parse_name_and_email(
110110
}
111111
let name = line[..start_bracket].trim().as_bstr();
112112
let rest = line[start_bracket + closing_bracket + 2..].as_bstr();
113-
Ok(((!name.is_empty()).then(|| name), Some(email), rest))
113+
Ok(((!name.is_empty()).then_some(name), Some(email), rest))
114114
}
115115
None => Ok((None, None, line)),
116116
}

Diff for: git-mailmap/src/snapshot/signature.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a> ResolvedSignature<'a> {
5151
) -> Option<Self> {
5252
let new_email = new_email
5353
.map(|n| n.as_bstr())
54-
.or_else(|| (matched_email != current_email).then(|| matched_email));
54+
.or_else(|| (matched_email != current_email).then_some(matched_email));
5555
match (new_email, new_name) {
5656
(None, None) => None,
5757
(new_email, new_name) => Some(ResolvedSignature {

Diff for: git-odb/src/store_impls/dynamic/handle.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<'a> IntraPackLookup<'a> {
4444
required_pack_index,
4545
} => index.lookup(id).and_then(|entry_index| {
4646
let (pack_index, pack_offset) = index.pack_id_and_pack_offset_at_index(entry_index);
47-
(pack_index == *required_pack_index).then(|| pack_offset)
47+
(pack_index == *required_pack_index).then_some(pack_offset)
4848
}),
4949
}
5050
}
@@ -90,7 +90,7 @@ pub(crate) mod index_lookup {
9090
"BUG: multi-pack index must be set if this is a multi-pack, pack-indices seem unstable",
9191
);
9292
Box::new(index.iter().filter_map(move |e| {
93-
(e.pack_index == pack_index).then(|| git_pack::index::Entry {
93+
(e.pack_index == pack_index).then_some(git_pack::index::Entry {
9494
oid: e.oid,
9595
pack_offset: e.pack_offset,
9696
crc32: None,

Diff for: git-odb/src/store_impls/dynamic/load_index.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl super::Store {
111111
match index
112112
.next_index_to_load
113113
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |current| {
114-
(current != index.slot_indices.len()).then(|| current + 1)
114+
(current != index.slot_indices.len()).then_some(current + 1)
115115
}) {
116116
Ok(slot_map_index) => {
117117
// This slot-map index is in bounds and was only given to us.
@@ -230,7 +230,7 @@ impl super::Store {
230230
let indices_by_modification_time = Self::collect_indices_and_mtime_sorted_by_size(
231231
db_paths,
232232
index.slot_indices.len().into(),
233-
self.use_multi_pack_index.then(|| self.object_hash),
233+
self.use_multi_pack_index.then_some(self.object_hash),
234234
)?;
235235
let mut idx_by_index_path: BTreeMap<_, _> = index
236236
.slot_indices
@@ -479,7 +479,7 @@ impl super::Store {
479479
(path != multi_index.path()
480480
&& !index_names_in_multi_index
481481
.contains(&Path::new(path.file_name().expect("file name present"))))
482-
.then(|| (Either::IndexPath(path), a, b))
482+
.then_some((Either::IndexPath(path), a, b))
483483
})
484484
.collect();
485485
indices_not_in_multi_index.insert(0, (Either::MultiIndexFile(Arc::new(multi_index)), mtime, flen));
@@ -488,7 +488,7 @@ impl super::Store {
488488
indices_by_modification_time.extend(
489489
indices
490490
.into_iter()
491-
.filter_map(|(p, a, b)| (!is_multipack_index(&p)).then(|| (Either::IndexPath(p), a, b))),
491+
.filter_map(|(p, a, b)| (!is_multipack_index(&p)).then_some((Either::IndexPath(p), a, b))),
492492
)
493493
}
494494
}

Diff for: git-pack/src/data/input/lookup_ref_delta_objects.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ where
155155
self.inserted_entry_length_at_offset
156156
.get(maybe_index_of_actual_entry)
157157
.and_then(|c| {
158-
(c.pack_offset == base_pack_offset).then(|| maybe_index_of_actual_entry)
158+
(c.pack_offset == base_pack_offset)
159+
.then_some(maybe_index_of_actual_entry)
159160
})
160161
.unwrap_or(index)
161162
};

Diff for: git-pack/src/data/output/entry/iter_from_counts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ where
178178
count,
179179
counts_in_pack,
180180
base_index_offset,
181-
allow_thin_pack.then(|| {
181+
allow_thin_pack.then_some({
182182
|pack_id, base_offset| {
183183
let (cached_pack_id, cache) = pack_offsets_to_id.get_or_insert_with(|| {
184184
db.pack_offsets_and_oid(pack_id)

Diff for: git-pack/src/multi_index/chunk.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ pub mod large_offsets {
244244
}
245245
}
246246

247-
needs_large_offsets.then(|| num_large_offsets)
247+
needs_large_offsets.then_some(num_large_offsets)
248248
}
249249
/// Returns true if the `offsets` range seems to be properly aligned for the data we expect.
250250
pub fn is_valid(offset: &Range<usize>) -> bool {
@@ -258,7 +258,7 @@ pub mod large_offsets {
258258
) -> std::io::Result<()> {
259259
for offset in sorted_entries
260260
.iter()
261-
.filter_map(|e| (e.pack_offset > LARGE_OFFSET_THRESHOLD).then(|| e.pack_offset))
261+
.filter_map(|e| (e.pack_offset > LARGE_OFFSET_THRESHOLD).then_some(e.pack_offset))
262262
{
263263
out.write_all(&offset.to_be_bytes())?;
264264
num_large_offsets = num_large_offsets

Diff for: git-pack/src/multi_index/init.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ impl TryFrom<&Path> for File {
104104

105105
let lookup = chunks.validated_usize_offset_by_id(chunk::lookup::ID, |offset| {
106106
chunk::lookup::is_valid(&offset, object_hash, num_objects)
107-
.then(|| offset)
107+
.then_some(offset)
108108
.ok_or(Error::InvalidChunkSize {
109109
id: chunk::lookup::ID,
110110
message: "The chunk with alphabetically ordered object ids doesn't have the correct size",
111111
})
112112
})??;
113113
let offsets = chunks.validated_usize_offset_by_id(chunk::offsets::ID, |offset| {
114114
chunk::offsets::is_valid(&offset, num_objects)
115-
.then(|| offset)
115+
.then_some(offset)
116116
.ok_or(Error::InvalidChunkSize {
117117
id: chunk::offsets::ID,
118118
message: "The chunk with offsets into the pack doesn't have the correct size",
@@ -121,7 +121,7 @@ impl TryFrom<&Path> for File {
121121
let large_offsets = chunks
122122
.validated_usize_offset_by_id(chunk::large_offsets::ID, |offset| {
123123
chunk::large_offsets::is_valid(&offset)
124-
.then(|| offset)
124+
.then_some(offset)
125125
.ok_or(Error::InvalidChunkSize {
126126
id: chunk::large_offsets::ID,
127127
message: "The chunk with large offsets into the pack doesn't have the correct size",

Diff for: git-pack/src/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub mod checksum {
2222
pub fn fan(data: &[u32]) -> Option<usize> {
2323
data.windows(2)
2424
.enumerate()
25-
.find_map(|(win_index, v)| (v[0] > v[1]).then(|| win_index))
25+
.find_map(|(win_index, v)| (v[0] > v[1]).then_some(win_index))
2626
}
2727

2828
/// Calculate the hash of the given kind by trying to read the file from disk at `data_path` or falling back on the mapped content in `data`.

Diff for: git-prompt/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl Options<'_> {
7575
.then(|| {
7676
std::env::var_os("GIT_TERMINAL_PROMPT")
7777
.and_then(|val| git_config_value::Boolean::try_from(val).ok())
78-
.and_then(|allow| (!allow.0).then(|| Mode::Disable))
78+
.and_then(|allow| (!allow.0).then_some(Mode::Disable))
7979
})
8080
.flatten()
8181
.unwrap_or(self.mode);

0 commit comments

Comments
 (0)