History

thanks clippy

Sebastian Thiel committed 3 years ago

Commit 345712d1 parent 6aa63b117 files · +31 −41Browse files

Unified · Split

17 files
  1. gix-attributes/src/search/outcome.rs +11 −12
  2. gix-config/src/parse/section/mod.rs +1 −1
  3. gix-filter/src/eol/convert_to_git.rs +1 −1
  4. gix-odb/src/store_impls/dynamic/load_index.rs +1 −1
  5. gix-pack/tests/pack/index.rs +1 −2
  6. gix-packetline/tests/encode/mod.rs +1 −3
  7. gix-packetline/tests/write/mod.rs +1 −5
  8. gix-pathspec/tests/search/mod.rs +2 −2
  9. gix-ref/src/store/packed/transaction.rs +1 −1
  10. gix-refspec/src/spec.rs +2 −2
  11. gix-revwalk/src/queue.rs +1 −1
  12. gix/src/clone/fetch/mod.rs +2 −2
  13. gix/src/clone/fetch/util.rs +1 −1
  14. gix/src/config/cache/access.rs +1 −1
  15. gix/src/config/tree/keys.rs +1 −1
  16. gix/src/repository/cache.rs +1 −1
  17. gix/tests/clone/mod.rs +2 −4
gix-attributes/src/search/outcome.rs+11−12
@@ -176,12 +176,11 @@ impl Outcome { · 175 unmodified lines
176176 source: Option<&std::path::PathBuf>,
177177 sequence_number: usize,
178178 ) -> bool {
179− self.attrs_stack.extend(attrs.filter_map(|attr| {
180− self.matches_by_id[attr.id.0]
181− .r#match
182− .is_none()
183− .then(|| (attr.id, attr.inner.clone(), None))
184− }));
179+ self.attrs_stack.extend(
180+ attrs
181+ .filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
182+ .map(|attr| (attr.id, attr.inner.clone(), None)),
183+ );
185184 while let Some((id, assignment, parent_order)) = self.attrs_stack.pop() {
186185 let slot = &mut self.matches_by_id[id.0];
187186 if slot.r#match.is_some() {
@@ -212,12 +211,12 @@ impl Outcome { · 24 unmodified lines
212211 if is_macro {
213212 // TODO(borrowchk): one fine day we should be able to re-borrow `slot` without having to redo the array access.
214213 let slot = &self.matches_by_id[id.0];
215− self.attrs_stack.extend(slot.macro_attributes.iter().filter_map(|attr| {
216− self.matches_by_id[attr.id.0]
217− .r#match
218− .is_none()
219− .then(|| (attr.id, attr.inner.clone(), Some(id)))
220− }));
214+ self.attrs_stack.extend(
215+ slot.macro_attributes
216+ .iter()
217+ .filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
218+ .map(|attr| (attr.id, attr.inner.clone(), Some(id))),
219+ );
221220 }
222221 }
223222 false
gix-config/src/parse/section/mod.rs+1−1
@@ -88,7 +88,7 @@ mod types { · 87 unmodified lines
8888
8989 impl PartialOrd for $name<'_> {
9090 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
91− self.cmp(other).into()
91+ Some(self.cmp(other))
9292 }
9393 }
9494
gix-filter/src/eol/convert_to_git.rs+1−1
@@ -81,7 +81,7 @@ pub(crate) mod function { · 80 unmodified lines
8181 return Ok(false);
8282 }
8383
84− if let Some(()) = index_object(buf).map_err(|err| Error::FetchObjectFromIndex(err))? {
84+ if let Some(()) = index_object(buf).map_err(Error::FetchObjectFromIndex)? {
8585 let has_crlf_in_index = buf
8686 .find_byte(b'\r')
8787 .map(|_| Stats::from_bytes(buf))
gix-odb/src/store_impls/dynamic/load_index.rs+1−1
@@ -711,7 +711,7 @@ impl PartialEq<Self> for Either { · 710 unmodified lines
711711
712712 impl PartialOrd<Self> for Either {
713713 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
714− self.path().partial_cmp(other.path())
714+ Some(self.path().cmp(other.path()))
715715 }
716716 }
717717
gix-pack/tests/pack/index.rs+1−2
@@ -409,8 +409,7 @@ fn pack_lookup() -> Result<(), Box<dyn std::error::Error>> { · 408 unmodified lines
409409 "iteration should yield the same pack offsets as the index"
410410 );
411411
412− let mut buf = Vec::new();
413− buf.resize(entry.decompressed_size as usize, 0);
412+ let mut buf = vec![0u8; entry.decompressed_size as usize];
414413 let pack_entry = pack.entry(offset_from_index);
415414 assert_eq!(
416415 pack_entry.pack_offset(),
gix-packetline/tests/encode/mod.rs+1−3
@@ -27,9 +27,7 @@ mod data_to_write { · 26 unmodified lines
2727 #[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
2828 async fn error_if_data_exceeds_limit() {
2929 fn vec_sized(size: usize) -> Vec<u8> {
30− let mut v = Vec::new();
31− v.resize(size, 0);
32− v
30+ vec![0; size]
3331 }
3432
3533 let res = data_to_write(&vec_sized(65516 + 1), io::sink()).await;
gix-packetline/tests/write/mod.rs+1−5
@@ -38,11 +38,7 @@ async fn write_text_and_write_binary() -> crate::Result { · 37 unmodified lines
3838 #[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
3939 async fn huge_writes_are_split_into_lines() -> crate::Result {
4040 let buf = {
41− let data = {
42− let mut v = Vec::new();
43− v.resize(MAX_DATA_LEN * 2, 0);
44− v
45− };
41+ let data = vec![0u8; MAX_DATA_LEN * 2];
4642 let mut w = Writer::new(Vec::new());
4743 w.write(&data).await?;
4844 w.into_inner()
gix-pathspec/tests/search/mod.rs+2−2
@@ -219,8 +219,8 @@ mod baseline { · 218 unmodified lines
219219 is_inconsistent = spec.as_bstr() == "git-inconsistency";
220220 !is_inconsistent
221221 })
222− .filter_map(|s| (!s.trim().is_empty()).then(|| s.trim()))
223− .map(|pathspec| gix_pathspec::parse(pathspec, Default::default()).expect("valid pathspec"))
222+ .filter(|s| !s.trim().is_empty())
223+ .map(|pathspec| gix_pathspec::parse(pathspec.trim(), Default::default()).expect("valid pathspec"))
224224 .collect();
225225 Expected {
226226 pathspecs,
gix-ref/src/store/packed/transaction.rs+1−1
@@ -78,7 +78,7 @@ impl packed::Transaction { · 77 unmodified lines
7878 edit.peeled = loop {
7979 let kind = find(next_id, &mut buf)?;
8080 match kind {
81− Some(kind) if kind == gix_object::Kind::Tag => {
81+ Some(gix_object::Kind::Tag) => {
8282 next_id = gix_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| {
8383 prepare::Error::Resolve(
8484 format!("Couldn't get target object id from tag {next_id}").into(),
gix-refspec/src/spec.rs+2−2
@@ -65,13 +65,13 @@ mod impls { · 64 unmodified lines
6565
6666 impl PartialOrd for RefSpecRef<'_> {
6767 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
68− self.instruction().partial_cmp(&other.instruction())
68+ Some(self.cmp(other))
6969 }
7070 }
7171
7272 impl PartialOrd for RefSpec {
7373 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
74− self.to_ref().partial_cmp(&other.to_ref())
74+ Some(self.to_ref().cmp(&other.to_ref()))
7575 }
7676 }
7777
gix-revwalk/src/queue.rs+1−1
@@ -29,7 +29,7 @@ impl<K: Ord, T> Eq for Item<K, T> {} · 28 unmodified lines
2929
3030 impl<K: Ord, T> PartialOrd<Self> for Item<K, T> {
3131 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
32− Ord::cmp(self, other).into()
32+ Some(Ord::cmp(self, other))
3333 }
3434 }
3535
gix/src/clone/fetch/mod.rs+2−2
@@ -94,7 +94,7 @@ impl PrepareFetch { · 93 unmodified lines
9494 .expect("valid static spec");
9595 let mut clone_fetch_tags = None;
9696 if let Some(f) = self.configure_remote.as_mut() {
97− remote = f(remote).map_err(|err| Error::RemoteConfiguration(err))?;
97+ remote = f(remote).map_err(Error::RemoteConfiguration)?;
9898 } else {
9999 clone_fetch_tags = remote::fetch::Tags::All.into();
100100 }
@@ -117,7 +117,7 @@ impl PrepareFetch { · 16 unmodified lines
117117 let pending_pack: remote::fetch::Prepare<'_, '_, _> = {
118118 let mut connection = remote.connect(remote::Direction::Fetch).await?;
119119 if let Some(f) = self.configure_connection.as_mut() {
120− f(&mut connection).map_err(|err| Error::RemoteConnection(err))?;
120+ f(&mut connection).map_err(Error::RemoteConnection)?;
121121 }
122122 connection
123123 .prepare_fetch(&mut *progress, {
gix/src/clone/fetch/util.rs+1−1
@@ -189,7 +189,7 @@ fn setup_branch_config( · 188 unmodified lines
189189 remote_name: &BStr,
190190 ) -> Result<(), Error> {
191191 let short_name = match branch.category_and_short_name() {
192− Some((cat, shortened)) if cat == gix_ref::Category::LocalBranch => match shortened.to_str() {
192+ Some((gix_ref::Category::LocalBranch, shortened)) => match shortened.to_str() {
193193 Ok(s) => s,
194194 Err(_) => return Ok(()),
195195 },
gix/src/config/cache/access.rs+1−1
@@ -303,7 +303,7 @@ impl Cache { · 302 unmodified lines
303303 &gitoxide::Pathspec::LITERAL,
304304 ]
305305 .iter()
306− .find_map(|key| (key.environment_override().expect("set") == name).then_some(key))
306+ .find(|key| key.environment_override().expect("set") == name)
307307 .expect("we must know all possible input variable names");
308308
309309 let val = self
gix/src/config/tree/keys.rs+1−1
@@ -237,7 +237,7 @@ mod lock_timeout { · 236 unmodified lines
237237 let value = value.map_err(|err| config::lock_timeout::Error::from(self).with_source(err))?;
238238 Ok(match value {
239239 val if val < 0 => Fail::AfterDurationWithBackoff(Duration::from_secs(u64::MAX)),
240− val if val == 0 => Fail::Immediately,
240+ 0 => Fail::Immediately,
241241 val => Fail::AfterDurationWithBackoff(Duration::from_millis(
242242 val.try_into().expect("i64 to u64 always works if positive"),
243243 )),
gix/src/repository/cache.rs+1−1
@@ -11,7 +11,7 @@ impl crate::Repository { · 10 unmodified lines
1111 pub fn object_cache_size(&mut self, bytes: impl Into<Option<usize>>) {
1212 let bytes = bytes.into();
1313 match bytes {
14− Some(bytes) if bytes == 0 => self.objects.unset_object_cache(),
14+ Some(0) => self.objects.unset_object_cache(),
1515 Some(bytes) => self
1616 .objects
1717 .set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes))),
gix/tests/clone/mod.rs+2−4
@@ -30,7 +30,6 @@ mod blocking_io { · 29 unmodified lines
3030 let mut prepare = gix::prepare_clone_bare(remote::repo("base").path(), tmp.path())?
3131 .with_remote_name(remote_name)?
3232 .configure_remote({
33− let called_configure_remote = called_configure_remote;
3433 move |r| {
3534 called_configure_remote.store(true, std::sync::atomic::Ordering::Relaxed);
3635 let mut r = r.with_fetch_tags(desired_fetch_tags);
@@ -372,14 +371,13 @@ mod blocking_io { · 335 unmodified lines
372371 .updates
373372 .iter()
374373 .enumerate()
375− .filter_map(|(idx, update)| {
374+ .filter(|(_, update)| {
376375 matches!(
377376 update.mode,
378377 gix::remote::fetch::refs::update::Mode::ImplicitTagNotSentByRemote
379378 )
380− .then(|| idx)
381379 })
382− .map(|idx| &out.ref_map.mappings[idx])
380+ .map(|(idx, _)| &out.ref_map.mappings[idx])
383381 {
384382 out_of_graph_tags.push(
385383 mapping