Unified · Split
| @@ -176,12 +176,11 @@ impl Outcome { · 175 unmodified lines | ||
| 176 | 176 | source: Option<&std::path::PathBuf>, |
| 177 | 177 | sequence_number: usize, |
| 178 | 178 | ) -> 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 | + ); | |
| 185 | 184 | while let Some((id, assignment, parent_order)) = self.attrs_stack.pop() { |
| 186 | 185 | let slot = &mut self.matches_by_id[id.0]; |
| 187 | 186 | if slot.r#match.is_some() { |
| @@ -212,12 +211,12 @@ impl Outcome { · 24 unmodified lines | ||
| 212 | 211 | if is_macro { |
| 213 | 212 | // TODO(borrowchk): one fine day we should be able to re-borrow `slot` without having to redo the array access. |
| 214 | 213 | 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 | + ); | |
| 221 | 220 | } |
| 222 | 221 | } |
| 223 | 222 | false |
| @@ -88,7 +88,7 @@ mod types { · 87 unmodified lines | ||
| 88 | 88 | |
| 89 | 89 | impl PartialOrd for $name<'_> { |
| 90 | 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 | |
| @@ -81,7 +81,7 @@ pub(crate) mod function { · 80 unmodified lines | ||
| 81 | 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 | 85 | let has_crlf_in_index = buf |
| 86 | 86 | .find_byte(b'\r') |
| 87 | 87 | .map(|_| Stats::from_bytes(buf)) |
| @@ -711,7 +711,7 @@ impl PartialEq<Self> for Either { · 710 unmodified lines | ||
| 711 | 711 | |
| 712 | 712 | impl PartialOrd<Self> for Either { |
| 713 | 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 | |
| @@ -409,8 +409,7 @@ fn pack_lookup() -> Result<(), Box<dyn std::error::Error>> { · 408 unmodified lines | ||
| 409 | 409 | "iteration should yield the same pack offsets as the index" |
| 410 | 410 | ); |
| 411 | 411 | |
| 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]; | |
| 414 | 413 | let pack_entry = pack.entry(offset_from_index); |
| 415 | 414 | assert_eq!( |
| 416 | 415 | pack_entry.pack_offset(), |
| @@ -27,9 +27,7 @@ mod data_to_write { · 26 unmodified lines | ||
| 27 | 27 | #[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))] |
| 28 | 28 | async fn error_if_data_exceeds_limit() { |
| 29 | 29 | fn vec_sized(size: usize) -> Vec<u8> { |
| 30 | − let mut v = Vec::new(); | |
| 31 | − v.resize(size, 0); | |
| 32 | − v | |
| 30 | + vec![0; size] | |
| 33 | 31 | } |
| 34 | 32 | |
| 35 | 33 | let res = data_to_write(&vec_sized(65516 + 1), io::sink()).await; |
| @@ -38,11 +38,7 @@ async fn write_text_and_write_binary() -> crate::Result { · 37 unmodified lines | ||
| 38 | 38 | #[maybe_async::test(feature = "blocking-io", async(feature = "async-io", async_std::test))] |
| 39 | 39 | async fn huge_writes_are_split_into_lines() -> crate::Result { |
| 40 | 40 | 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]; | |
| 46 | 42 | let mut w = Writer::new(Vec::new()); |
| 47 | 43 | w.write(&data).await?; |
| 48 | 44 | w.into_inner() |
| @@ -219,8 +219,8 @@ mod baseline { · 218 unmodified lines | ||
| 219 | 219 | is_inconsistent = spec.as_bstr() == "git-inconsistency"; |
| 220 | 220 | !is_inconsistent |
| 221 | 221 | }) |
| 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")) | |
| 224 | 224 | .collect(); |
| 225 | 225 | Expected { |
| 226 | 226 | pathspecs, |
| @@ -78,7 +78,7 @@ impl packed::Transaction { · 77 unmodified lines | ||
| 78 | 78 | edit.peeled = loop { |
| 79 | 79 | let kind = find(next_id, &mut buf)?; |
| 80 | 80 | match kind { |
| 81 | − Some(kind) if kind == gix_object::Kind::Tag => { | |
| 81 | + Some(gix_object::Kind::Tag) => { | |
| 82 | 82 | next_id = gix_object::TagRefIter::from_bytes(&buf).target_id().map_err(|_| { |
| 83 | 83 | prepare::Error::Resolve( |
| 84 | 84 | format!("Couldn't get target object id from tag {next_id}").into(), |
| @@ -65,13 +65,13 @@ mod impls { · 64 unmodified lines | ||
| 65 | 65 | |
| 66 | 66 | impl PartialOrd for RefSpecRef<'_> { |
| 67 | 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 | 72 | impl PartialOrd for RefSpec { |
| 73 | 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 | |
| @@ -29,7 +29,7 @@ impl<K: Ord, T> Eq for Item<K, T> {} · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | impl<K: Ord, T> PartialOrd<Self> for Item<K, T> { |
| 31 | 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 | |
| @@ -94,7 +94,7 @@ impl PrepareFetch { · 93 unmodified lines | ||
| 94 | 94 | .expect("valid static spec"); |
| 95 | 95 | let mut clone_fetch_tags = None; |
| 96 | 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 | 98 | } else { |
| 99 | 99 | clone_fetch_tags = remote::fetch::Tags::All.into(); |
| 100 | 100 | } |
| @@ -117,7 +117,7 @@ impl PrepareFetch { · 16 unmodified lines | ||
| 117 | 117 | let pending_pack: remote::fetch::Prepare<'_, '_, _> = { |
| 118 | 118 | let mut connection = remote.connect(remote::Direction::Fetch).await?; |
| 119 | 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 | 122 | connection |
| 123 | 123 | .prepare_fetch(&mut *progress, { |
| @@ -189,7 +189,7 @@ fn setup_branch_config( · 188 unmodified lines | ||
| 189 | 189 | remote_name: &BStr, |
| 190 | 190 | ) -> Result<(), Error> { |
| 191 | 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 | 193 | Ok(s) => s, |
| 194 | 194 | Err(_) => return Ok(()), |
| 195 | 195 | }, |
| @@ -303,7 +303,7 @@ impl Cache { · 302 unmodified lines | ||
| 303 | 303 | &gitoxide::Pathspec::LITERAL, |
| 304 | 304 | ] |
| 305 | 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 | 307 | .expect("we must know all possible input variable names"); |
| 308 | 308 | |
| 309 | 309 | let val = self |
| @@ -237,7 +237,7 @@ mod lock_timeout { · 236 unmodified lines | ||
| 237 | 237 | let value = value.map_err(|err| config::lock_timeout::Error::from(self).with_source(err))?; |
| 238 | 238 | Ok(match value { |
| 239 | 239 | val if val < 0 => Fail::AfterDurationWithBackoff(Duration::from_secs(u64::MAX)), |
| 240 | − val if val == 0 => Fail::Immediately, | |
| 240 | + 0 => Fail::Immediately, | |
| 241 | 241 | val => Fail::AfterDurationWithBackoff(Duration::from_millis( |
| 242 | 242 | val.try_into().expect("i64 to u64 always works if positive"), |
| 243 | 243 | )), |
| @@ -11,7 +11,7 @@ impl crate::Repository { · 10 unmodified lines | ||
| 11 | 11 | pub fn object_cache_size(&mut self, bytes: impl Into<Option<usize>>) { |
| 12 | 12 | let bytes = bytes.into(); |
| 13 | 13 | match bytes { |
| 14 | − Some(bytes) if bytes == 0 => self.objects.unset_object_cache(), | |
| 14 | + Some(0) => self.objects.unset_object_cache(), | |
| 15 | 15 | Some(bytes) => self |
| 16 | 16 | .objects |
| 17 | 17 | .set_object_cache(move || Box::new(crate::object::cache::MemoryCappedHashmap::new(bytes))), |
| @@ -30,7 +30,6 @@ mod blocking_io { · 29 unmodified lines | ||
| 30 | 30 | let mut prepare = gix::prepare_clone_bare(remote::repo("base").path(), tmp.path())? |
| 31 | 31 | .with_remote_name(remote_name)? |
| 32 | 32 | .configure_remote({ |
| 33 | − let called_configure_remote = called_configure_remote; | |
| 34 | 33 | move |r| { |
| 35 | 34 | called_configure_remote.store(true, std::sync::atomic::Ordering::Relaxed); |
| 36 | 35 | let mut r = r.with_fetch_tags(desired_fetch_tags); |
| @@ -372,14 +371,13 @@ mod blocking_io { · 335 unmodified lines | ||
| 372 | 371 | .updates |
| 373 | 372 | .iter() |
| 374 | 373 | .enumerate() |
| 375 | − .filter_map(|(idx, update)| { | |
| 374 | + .filter(|(_, update)| { | |
| 376 | 375 | matches!( |
| 377 | 376 | update.mode, |
| 378 | 377 | 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 | 382 | out_of_graph_tags.push( |
| 385 | 383 | mapping |