History

thanks clippy

Sebastian Thiel committed 2 years ago

Commit d38d1cc1 parent 859a0927 files · +43 −44Browse files

Unified · Split

7 files
  1. gix-config/src/parse/section/header.rs +18 −18
  2. gix-odb/tests/odb/mod.rs +0 −1
  3. gix-packetline/src/read/sidebands/async_io.rs +18 −18
  4. gix-protocol/tests/fetch/response.rs +2 −1
  5. gix-ref/src/store/file/find.rs +2 −3
  6. gix/src/remote/connection/fetch/update_refs/tests.rs +2 −2
  7. gix/src/remote/url/scheme_permission.rs +1 −1
gix-config/src/parse/section/header.rs+18−18
@@ -59,24 +59,6 @@ fn validated_name(name: Cow<'_, BStr>) -> Result<Cow<'_, BStr>, Error> { · 58 unmodified lines
5959 .ok_or(Error::InvalidName)
6060 }
6161
62−#[cfg(test)]
63−mod tests {
64− use super::*;
65−
66− #[test]
67− fn empty_header_names_are_legal() {
68− assert!(Header::new("", None).is_ok(), "yes, git allows this, so do we");
69− }
70−
71− #[test]
72− fn empty_header_sub_names_are_legal() {
73− assert!(
74− Header::new("remote", Some(Cow::Borrowed("".into()))).is_ok(),
75− "yes, git allows this, so do we"
76− );
77− }
78−}
79−
8062 impl Header<'_> {
8163 ///Return true if this is a header like `[legacy.subsection]`, or false otherwise.
8264 pub fn is_legacy(&self) -> bool {
@@ -178,3 +160,21 @@ impl<'a> From<Header<'a>> for Event<'a> { · 95 unmodified lines
178160 Event::SectionHeader(header)
179161 }
180162 }
163+
164+#[cfg(test)]
165+mod tests {
166+ use super::*;
167+
168+ #[test]
169+ fn empty_header_names_are_legal() {
170+ assert!(Header::new("", None).is_ok(), "yes, git allows this, so do we");
171+ }
172+
173+ #[test]
174+ fn empty_header_sub_names_are_legal() {
175+ assert!(
176+ Header::new("remote", Some(Cow::Borrowed("".into()))).is_ok(),
177+ "yes, git allows this, so do we"
178+ );
179+ }
180+}
gix-odb/tests/odb/mod.rs+0−1
@@ -1,6 +1,5 @@
11 use gix_hash::ObjectId;
22 use gix_testtools::fixture_path_standalone;
3−pub use gix_testtools::{fixture_path, scripted_fixture_read_only};
43
54 pub fn hex_to_id(hex: &str) -> ObjectId {
65 ObjectId::from_hex(hex.as_bytes()).expect("40 bytes hex")
gix-packetline/src/read/sidebands/async_io.rs+18−18
@@ -72,24 +72,6 @@ enum State<'a, T> { · 71 unmodified lines
7272 #[allow(unsafe_code, clippy::non_send_fields_in_send_ty)]
7373 unsafe impl<'a, T> Send for State<'a, T> where T: Send {}
7474
75−#[cfg(test)]
76−mod tests {
77− use super::*;
78− fn receiver<T: Send>(_i: T) {}
79−
80− /// We want to declare items containing pointers of `StreamingPeekableIter` `Send` as well, so it must be `Send` itself.
81− #[test]
82− fn streaming_peekable_iter_is_send() {
83− receiver(StreamingPeekableIter::new(Vec::<u8>::new(), &[], false));
84− }
85−
86− #[test]
87− fn state_is_send() {
88− let mut s = StreamingPeekableIter::new(Vec::<u8>::new(), &[], false);
89− receiver(State::Idle { parent: Some(&mut s) });
90− }
91−}
92−
9375 impl<'a, T, F> WithSidebands<'a, T, F>
9476 where
9577 T: AsyncRead + Unpin,
@@ -381,3 +363,21 @@ where · 285 unmodified lines
381363 Poll::Ready(Ok(nread))
382364 }
383365 }
366+
367+#[cfg(test)]
368+mod tests {
369+ use super::*;
370+ fn receiver<T: Send>(_i: T) {}
371+
372+ /// We want to declare items containing pointers of `StreamingPeekableIter` `Send` as well, so it must be `Send` itself.
373+ #[test]
374+ fn streaming_peekable_iter_is_send() {
375+ receiver(StreamingPeekableIter::new(Vec::<u8>::new(), &[], false));
376+ }
377+
378+ #[test]
379+ fn state_is_send() {
380+ let mut s = StreamingPeekableIter::new(Vec::<u8>::new(), &[], false);
381+ receiver(State::Idle { parent: Some(&mut s) });
382+ }
383+}
gix-protocol/tests/fetch/response.rs+2−1
@@ -317,7 +317,8 @@ mod v2 { · 316 unmodified lines
317317 assert_eq!(bytes_read, 1643, "should be able to read the whole pack");
318318 assert_eq!(&buf[..4], b"PACK");
319319 assert_eq!(
320− gix_hash::ObjectId::from(&buf[buf.len() - gix_hash::Kind::Sha1.len_in_bytes()..]).to_string(),
320+ gix_hash::ObjectId::from_bytes_or_panic(&buf[buf.len() - gix_hash::Kind::Sha1.len_in_bytes()..])
321+ .to_string(),
321322 "f34c9be7e0c3ef2c3ed7c62cc7791dbf6dc5ec9a"
322323 );
323324 Ok(())
gix-ref/src/store/file/find.rs+2−3
@@ -45,7 +45,7 @@ impl file::Store { · 44 unmodified lines
4545 Error: From<E>,
4646 {
4747 self.find_one_with_verified_input(partial.try_into()?, None)
48− .map(|r| r.map(|r| r.try_into().expect("only loose refs are found without pack")))
48+ .map(|r| r.map(Into::into))
4949 }
5050
5151 /// Similar to [`file::Store::find()`], but allows to pass a snapshotted packed buffer instead.
@@ -267,8 +267,7 @@ pub mod existing { · 215 unmodified lines
267267 Name: TryInto<&'a PartialNameRef, Error = E>,
268268 crate::name::Error: From<E>,
269269 {
270− self.find_existing_inner(partial, None)
271− .map(|r| r.try_into().expect("always loose without packed"))
270+ self.find_existing_inner(partial, None).map(Into::into)
272271 }
273272
274273 /// Similar to [`file::Store::find()`] but a non-existing ref is treated as error.
gix/src/remote/connection/fetch/update_refs/tests.rs+2−2
@@ -605,7 +605,7 @@ mod update { · 604 unmodified lines
605605 let (mut mappings, specs) = mapping_from_spec("refs/heads/symbolic:refs/remotes/origin/new", &repo);
606606 mappings.push(Mapping {
607607 remote: Source::Ref(gix_protocol::handshake::Ref::Direct {
608− full_ref_name: "refs/heads/main".try_into().unwrap(),
608+ full_ref_name: "refs/heads/main".into(),
609609 object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"),
610610 }),
611611 local: Some("refs/heads/symbolic".into()),
@@ -728,7 +728,7 @@ mod update { · 116 unmodified lines
728728 let (mut mappings, specs) = mapping_from_spec("HEAD:refs/remotes/origin/new-HEAD", &repo);
729729 mappings.push(Mapping {
730730 remote: Source::Ref(gix_protocol::handshake::Ref::Direct {
731− full_ref_name: "refs/heads/main".try_into().unwrap(),
731+ full_ref_name: "refs/heads/main".into(),
732732 object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"),
733733 }),
734734 local: Some("refs/remotes/origin/main".into()),
gix/src/remote/url/scheme_permission.rs+1−1
@@ -72,7 +72,7 @@ impl SchemePermission { · 71 unmodified lines
7272 scheme
7373 .to_str()
7474 .ok()
75− .and_then(|scheme| gix_url::Scheme::try_from(scheme).ok().map(|scheme| (section, scheme)))
75+ .map(|scheme| (section, gix_url::Scheme::from(scheme)))
7676 })
7777 }) {
7878 if let Some(value) = section