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
176 source: Option<&std::path::PathBuf>,176 source: Option<&std::path::PathBuf>,
177 sequence_number: usize,177 sequence_number: usize,
178 ) -> bool {178 ) -> bool {
179 self.attrs_stack.extend(attrs.filter_map(|attr| {179 self.attrs_stack.extend(
180 self.matches_by_id[attr.id.0]180 attrs
181 .r#match181 .filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
182 .is_none()182 .map(|attr| (attr.id, attr.inner.clone(), None)),
183 .then(|| (attr.id, attr.inner.clone(), None))183 );
184 }));
185 while let Some((id, assignment, parent_order)) = self.attrs_stack.pop() {184 while let Some((id, assignment, parent_order)) = self.attrs_stack.pop() {
186 let slot = &mut self.matches_by_id[id.0];185 let slot = &mut self.matches_by_id[id.0];
187 if slot.r#match.is_some() {186 if slot.r#match.is_some() {
@@ -212,12 +211,12 @@ impl Outcome { · 24 unmodified lines
212 if is_macro {211 if is_macro {
213 // TODO(borrowchk): one fine day we should be able to re-borrow `slot` without having to redo the array access.212 // TODO(borrowchk): one fine day we should be able to re-borrow `slot` without having to redo the array access.
214 let slot = &self.matches_by_id[id.0];213 let slot = &self.matches_by_id[id.0];
215 self.attrs_stack.extend(slot.macro_attributes.iter().filter_map(|attr| {214 self.attrs_stack.extend(
216 self.matches_by_id[attr.id.0]215 slot.macro_attributes
217 .r#match216 .iter()
218 .is_none()217 .filter(|attr| self.matches_by_id[attr.id.0].r#match.is_none())
219 .then(|| (attr.id, attr.inner.clone(), Some(id)))218 .map(|attr| (attr.id, attr.inner.clone(), Some(id))),
220 }));219 );
221 }220 }
222 }221 }
223 false222 false
gix-config/src/parse/section/mod.rs+1−1
@@ -88,7 +88,7 @@ mod types { · 87 unmodified lines
88 88
89 impl PartialOrd for $name<'_> {89 impl PartialOrd for $name<'_> {
90 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {90 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
91 self.cmp(other).into()91 Some(self.cmp(other))
92 }92 }
93 }93 }
94 94
gix-filter/src/eol/convert_to_git.rs+1−1
@@ -81,7 +81,7 @@ pub(crate) mod function { · 80 unmodified lines
81 return Ok(false);81 return Ok(false);
82 }82 }
83 83
84 if let Some(()) = index_object(buf).map_err(|err| Error::FetchObjectFromIndex(err))? {84 if let Some(()) = index_object(buf).map_err(Error::FetchObjectFromIndex)? {
85 let has_crlf_in_index = buf85 let has_crlf_in_index = buf
86 .find_byte(b'\r')86 .find_byte(b'\r')
87 .map(|_| Stats::from_bytes(buf))87 .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
711 711
712impl PartialOrd<Self> for Either {712impl PartialOrd<Self> for Either {
713 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {713 fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
714 self.path().partial_cmp(other.path())714 Some(self.path().cmp(other.path()))
715 }715 }
716}716}
717 717
gix-pack/tests/pack/index.rs+1−2
@@ -409,8 +409,7 @@ fn pack_lookup() -> Result<(), Box<dyn std::error::Error>> { · 408 unmodified lines
409 "iteration should yield the same pack offsets as the index"409 "iteration should yield the same pack offsets as the index"
410 );410 );
411 411
412 let mut buf = Vec::new();412 let mut buf = vec![0u8; entry.decompressed_size as usize];
413 buf.resize(entry.decompressed_size as usize, 0);
414 let pack_entry = pack.entry(offset_from_index);413 let pack_entry = pack.entry(offset_from_index);
415 assert_eq!(414 assert_eq!(
416 pack_entry.pack_offset(),415 pack_entry.pack_offset(),
gix-packetline/tests/encode/mod.rs+1−3
@@ -27,9 +27,7 @@ mod data_to_write { · 26 unmodified lines
27 #[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]27 #[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
28 async fn error_if_data_exceeds_limit() {28 async fn error_if_data_exceeds_limit() {
29 fn vec_sized(size: usize) -> Vec<u8> {29 fn vec_sized(size: usize) -> Vec<u8> {
30 let mut v = Vec::new();30 vec![0; size]
31 v.resize(size, 0);
32 v
33 }31 }
34 32
35 let res = data_to_write(&vec_sized(65516 + 1), io::sink()).await;33 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
38#[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]38#[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))]
39async fn huge_writes_are_split_into_lines() -> crate::Result {39async fn huge_writes_are_split_into_lines() -> crate::Result {
40 let buf = {40 let buf = {
41 let data = {41 let data = vec![0u8; MAX_DATA_LEN * 2];
42 let mut v = Vec::new();
43 v.resize(MAX_DATA_LEN * 2, 0);
44 v
45 };
46 let mut w = Writer::new(Vec::new());42 let mut w = Writer::new(Vec::new());
47 w.write(&data).await?;43 w.write(&data).await?;
48 w.into_inner()44 w.into_inner()
gix-pathspec/tests/search/mod.rs+2−2
@@ -219,8 +219,8 @@ mod baseline { · 218 unmodified lines
219 is_inconsistent = spec.as_bstr() == "git-inconsistency";219 is_inconsistent = spec.as_bstr() == "git-inconsistency";
220 !is_inconsistent220 !is_inconsistent
221 })221 })
222 .filter_map(|s| (!s.trim().is_empty()).then(|| s.trim()))222 .filter(|s| !s.trim().is_empty())
223 .map(|pathspec| gix_pathspec::parse(pathspec, Default::default()).expect("valid pathspec"))223 .map(|pathspec| gix_pathspec::parse(pathspec.trim(), Default::default()).expect("valid pathspec"))
224 .collect();224 .collect();
225 Expected {225 Expected {
226 pathspecs,226 pathspecs,
gix-ref/src/store/packed/transaction.rs+1−1
@@ -78,7 +78,7 @@ impl packed::Transaction { · 77 unmodified lines
78 edit.peeled = loop {78 edit.peeled = loop {
79 let kind = find(next_id, &mut buf)?;79 let kind = find(next_id, &mut buf)?;
80 match kind {80 match kind {
81 Some(kind) if kind == gix_object::Kind::Tag => {81 Some(gix_object::Kind::Tag) => {
82 next_id = gix_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| {82 next_id = gix_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| {
83 prepare::Error::Resolve(83 prepare::Error::Resolve(
84 format!("Couldn't get target object id from tag {next_id}").into(),84 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
65 65
66 impl PartialOrd for RefSpecRef<'_> {66 impl PartialOrd for RefSpecRef<'_> {
67 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {67 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
68 self.instruction().partial_cmp(&other.instruction())68 Some(self.cmp(other))
69 }69 }
70 }70 }
71 71
72 impl PartialOrd for RefSpec {72 impl PartialOrd for RefSpec {
73 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {73 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()))
75 }75 }
76 }76 }
77 77
gix-revwalk/src/queue.rs+1−1
@@ -29,7 +29,7 @@ impl<K: Ord, T> Eq for Item<K, T> {} · 28 unmodified lines
29 29
30impl<K: Ord, T> PartialOrd<Self> for Item<K, T> {30impl<K: Ord, T> PartialOrd<Self> for Item<K, T> {
31 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {31 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
32 Ord::cmp(self, other).into()32 Some(Ord::cmp(self, other))
33 }33 }
34}34}
35 35
gix/src/clone/fetch/mod.rs+2−2
@@ -94,7 +94,7 @@ impl PrepareFetch { · 93 unmodified lines
94 .expect("valid static spec");94 .expect("valid static spec");
95 let mut clone_fetch_tags = None;95 let mut clone_fetch_tags = None;
96 if let Some(f) = self.configure_remote.as_mut() {96 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)?;
98 } else {98 } else {
99 clone_fetch_tags = remote::fetch::Tags::All.into();99 clone_fetch_tags = remote::fetch::Tags::All.into();
100 }100 }
@@ -117,7 +117,7 @@ impl PrepareFetch { · 16 unmodified lines
117 let pending_pack: remote::fetch::Prepare<'_, '_, _> = {117 let pending_pack: remote::fetch::Prepare<'_, '_, _> = {
118 let mut connection = remote.connect(remote::Direction::Fetch).await?;118 let mut connection = remote.connect(remote::Direction::Fetch).await?;
119 if let Some(f) = self.configure_connection.as_mut() {119 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)?;
121 }121 }
122 connection122 connection
123 .prepare_fetch(&mut *progress, {123 .prepare_fetch(&mut *progress, {
gix/src/clone/fetch/util.rs+1−1
@@ -189,7 +189,7 @@ fn setup_branch_config( · 188 unmodified lines
189 remote_name: &BStr,189 remote_name: &BStr,
190) -> Result<(), Error> {190) -> Result<(), Error> {
191 let short_name = match branch.category_and_short_name() {191 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() {
193 Ok(s) => s,193 Ok(s) => s,
194 Err(_) => return Ok(()),194 Err(_) => return Ok(()),
195 },195 },
gix/src/config/cache/access.rs+1−1
@@ -303,7 +303,7 @@ impl Cache { · 302 unmodified lines
303 &gitoxide::Pathspec::LITERAL,303 &gitoxide::Pathspec::LITERAL,
304 ]304 ]
305 .iter()305 .iter()
306 .find_map(|key| (key.environment_override().expect("set") == name).then_some(key))306 .find(|key| key.environment_override().expect("set") == name)
307 .expect("we must know all possible input variable names");307 .expect("we must know all possible input variable names");
308 308
309 let val = self309 let val = self
gix/src/config/tree/keys.rs+1−1
@@ -237,7 +237,7 @@ mod lock_timeout { · 236 unmodified lines
237 let value = value.map_err(|err| config::lock_timeout::Error::from(self).with_source(err))?;237 let value = value.map_err(|err| config::lock_timeout::Error::from(self).with_source(err))?;
238 Ok(match value {238 Ok(match value {
239 val if val < 0 => Fail::AfterDurationWithBackoff(Duration::from_secs(u64::MAX)),239 val if val < 0 => Fail::AfterDurationWithBackoff(Duration::from_secs(u64::MAX)),
240 val if val == 0 => Fail::Immediately,240 0 => Fail::Immediately,
241 val => Fail::AfterDurationWithBackoff(Duration::from_millis(241 val => Fail::AfterDurationWithBackoff(Duration::from_millis(
242 val.try_into().expect("i64 to u64 always works if positive"),242 val.try_into().expect("i64 to u64 always works if positive"),
243 )),243 )),
gix/src/repository/cache.rs+1−1
@@ -11,7 +11,7 @@ impl crate::Repository { · 10 unmodified lines
11 pub fn object_cache_size(&mut self, bytes: impl Into<Option<usize>>) {11 pub fn object_cache_size(&mut self, bytes: impl Into<Option<usize>>) {
12 let bytes = bytes.into();12 let bytes = bytes.into();
13 match bytes {13 match bytes {
14 Some(bytes) if bytes == 0 => self.objects.unset_object_cache(),14 Some(0) => self.objects.unset_object_cache(),
15 Some(bytes) => self15 Some(bytes) => self
16 .objects16 .objects
17 .set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes))),17 .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
30 let mut prepare = gix::prepare_clone_bare(remote::repo("base").path(), tmp.path())?30 let mut prepare = gix::prepare_clone_bare(remote::repo("base").path(), tmp.path())?
31 .with_remote_name(remote_name)?31 .with_remote_name(remote_name)?
32 .configure_remote({32 .configure_remote({
33 let called_configure_remote = called_configure_remote;
34 move |r| {33 move |r| {
35 called_configure_remote.store(true, std::sync::atomic::Ordering::Relaxed);34 called_configure_remote.store(true, std::sync::atomic::Ordering::Relaxed);
36 let mut r = r.with_fetch_tags(desired_fetch_tags);35 let mut r = r.with_fetch_tags(desired_fetch_tags);
@@ -372,14 +371,13 @@ mod blocking_io { · 335 unmodified lines
372 .updates371 .updates
373 .iter()372 .iter()
374 .enumerate()373 .enumerate()
375 .filter_map(|(idx, update)| {374 .filter(|(_, update)| {
376 matches!(375 matches!(
377 update.mode,376 update.mode,
378 gix::remote::fetch::refs::update::Mode::ImplicitTagNotSentByRemote377 gix::remote::fetch::refs::update::Mode::ImplicitTagNotSentByRemote
379 )378 )
380 .then(|| idx)
381 })379 })
382 .map(|idx| &out.ref_map.mappings[idx])380 .map(|(idx, _)| &out.ref_map.mappings[idx])
383 {381 {
384 out_of_graph_tags.push(382 out_of_graph_tags.push(
385 mapping383 mapping