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
59 .ok_or(Error::InvalidName)59 .ok_or(Error::InvalidName)
60}60}
61 61
62#[cfg(test)]
63mod 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
80impl Header<'_> {62impl Header<'_> {
81 ///Return true if this is a header like `[legacy.subsection]`, or false otherwise.63 ///Return true if this is a header like `[legacy.subsection]`, or false otherwise.
82 pub fn is_legacy(&self) -> bool {64 pub fn is_legacy(&self) -> bool {
@@ -178,3 +160,21 @@ impl<'a> From<Header<'a>> for Event<'a> { · 95 unmodified lines
178 Event::SectionHeader(header)160 Event::SectionHeader(header)
179 }161 }
180}162}
163
164#[cfg(test)]
165mod 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 @@
1use gix_hash::ObjectId;1use gix_hash::ObjectId;
2use gix_testtools::fixture_path_standalone;2use gix_testtools::fixture_path_standalone;
3pub use gix_testtools::{fixture_path, scripted_fixture_read_only};
4 3
5pub fn hex_to_id(hex: &str) -> ObjectId {4pub fn hex_to_id(hex: &str) -> ObjectId {
6 ObjectId::from_hex(hex.as_bytes()).expect("40 bytes hex")5 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
72#[allow(unsafe_code, clippy::non_send_fields_in_send_ty)]72#[allow(unsafe_code, clippy::non_send_fields_in_send_ty)]
73unsafe impl<'a, T> Send for State<'a, T> where T: Send {}73unsafe impl<'a, T> Send for State<'a, T> where T: Send {}
74 74
75#[cfg(test)]
76mod 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
93impl<'a, T, F> WithSidebands<'a, T, F>75impl<'a, T, F> WithSidebands<'a, T, F>
94where76where
95 T: AsyncRead + Unpin,77 T: AsyncRead + Unpin,
@@ -381,3 +363,21 @@ where · 285 unmodified lines
381 Poll::Ready(Ok(nread))363 Poll::Ready(Ok(nread))
382 }364 }
383}365}
366
367#[cfg(test)]
368mod 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
317 assert_eq!(bytes_read, 1643, "should be able to read the whole pack");317 assert_eq!(bytes_read, 1643, "should be able to read the whole pack");
318 assert_eq!(&buf[..4], b"PACK");318 assert_eq!(&buf[..4], b"PACK");
319 assert_eq!(319 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(),
321 "f34c9be7e0c3ef2c3ed7c62cc7791dbf6dc5ec9a"322 "f34c9be7e0c3ef2c3ed7c62cc7791dbf6dc5ec9a"
322 );323 );
323 Ok(())324 Ok(())
gix-ref/src/store/file/find.rs+2−3
@@ -45,7 +45,7 @@ impl file::Store { · 44 unmodified lines
45 Error: From<E>,45 Error: From<E>,
46 {46 {
47 self.find_one_with_verified_input(partial.try_into()?, None)47 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))
49 }49 }
50 50
51 /// Similar to [`file::Store::find()`], but allows to pass a snapshotted packed buffer instead.51 /// Similar to [`file::Store::find()`], but allows to pass a snapshotted packed buffer instead.
@@ -267,8 +267,7 @@ pub mod existing { · 215 unmodified lines
267 Name: TryInto<&'a PartialNameRef, Error = E>,267 Name: TryInto<&'a PartialNameRef, Error = E>,
268 crate::name::Error: From<E>,268 crate::name::Error: From<E>,
269 {269 {
270 self.find_existing_inner(partial, None)270 self.find_existing_inner(partial, None).map(Into::into)
271 .map(|r| r.try_into().expect("always loose without packed"))
272 }271 }
273 272
274 /// Similar to [`file::Store::find()`] but a non-existing ref is treated as error.273 /// 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
605 let (mut mappings, specs) = mapping_from_spec("refs/heads/symbolic:refs/remotes/origin/new", &repo);605 let (mut mappings, specs) = mapping_from_spec("refs/heads/symbolic:refs/remotes/origin/new", &repo);
606 mappings.push(Mapping {606 mappings.push(Mapping {
607 remote: Source::Ref(gix_protocol::handshake::Ref::Direct {607 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(),
609 object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"),609 object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"),
610 }),610 }),
611 local: Some("refs/heads/symbolic".into()),611 local: Some("refs/heads/symbolic".into()),
@@ -728,7 +728,7 @@ mod update { · 116 unmodified lines
728 let (mut mappings, specs) = mapping_from_spec("HEAD:refs/remotes/origin/new-HEAD", &repo);728 let (mut mappings, specs) = mapping_from_spec("HEAD:refs/remotes/origin/new-HEAD", &repo);
729 mappings.push(Mapping {729 mappings.push(Mapping {
730 remote: Source::Ref(gix_protocol::handshake::Ref::Direct {730 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(),
732 object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"),732 object: hex_to_id("f99771fe6a1b535783af3163eba95a927aae21d5"),
733 }),733 }),
734 local: Some("refs/remotes/origin/main".into()),734 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
72 scheme72 scheme
73 .to_str()73 .to_str()
74 .ok()74 .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)))
76 })76 })
77 }) {77 }) {
78 if let Some(value) = section78 if let Some(value) = section