diff --git a/rust/hg-core/src/dirstate_tree/dirstate_map.rs b/rust/hg-core/src/dirstate_tree/dirstate_map.rs --- a/rust/hg-core/src/dirstate_tree/dirstate_map.rs +++ b/rust/hg-core/src/dirstate_tree/dirstate_map.rs @@ -427,19 +427,14 @@ pub(super) struct Node<'on_disk> { pub(super) tracked_descendants_count: u32, } -#[derive(Debug)] +#[derive(Debug, Default)] pub(super) enum NodeData { Entry(DirstateEntry), CachedDirectory { mtime: TruncatedTimestamp }, + #[default] None, } -impl Default for NodeData { - fn default() -> Self { - NodeData::None - } -} - impl NodeData { fn has_entry(&self) -> bool { matches!(self, NodeData::Entry(_)) diff --git a/rust/hg-core/src/dirstate_tree/on_disk.rs b/rust/hg-core/src/dirstate_tree/on_disk.rs --- a/rust/hg-core/src/dirstate_tree/on_disk.rs +++ b/rust/hg-core/src/dirstate_tree/on_disk.rs @@ -332,9 +332,7 @@ impl Node { ) -> Result { let start = self.base_name_start.get(); if start < self.full_path.len.get() { - let start = usize::try_from(start) - // u32 -> usize, could only panic on a 16-bit CPU - .expect("dirstate-v2 base_name_start out of bounds"); + let start = usize::from(start); Ok(start) } else { Err(DirstateV2ParseError::new("not enough bytes for base name")) @@ -593,8 +591,8 @@ where { // Either `usize::MAX` would result in "out of bounds" error since a single // `&[u8]` cannot occupy the entire addess space. - let start = start.get().try_into().unwrap_or(std::usize::MAX); - let len = len.try_into().unwrap_or(std::usize::MAX); + let start = start.get().try_into().unwrap_or(usize::MAX); + let len = len.try_into().unwrap_or(usize::MAX); let bytes = match on_disk.get(start..) { Some(bytes) => bytes, None => { diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs --- a/rust/hg-core/src/matchers.rs +++ b/rust/hg-core/src/matchers.rs @@ -617,7 +617,11 @@ impl IntersectionMatcher { std::mem::swap(&mut m1, &mut m2); } m1.file_set().map(|m1_files| { - m1_files.iter().cloned().filter(|f| m2.matches(f)).collect() + m1_files + .iter() + .filter(|&f| m2.matches(f)) + .cloned() + .collect() }) } else { // without exact input file sets, we can't do an exact @@ -710,7 +714,7 @@ impl DifferenceMatcher { }; if base_is_exact { new.files = base_files.map(|files| { - files.iter().cloned().filter(|f| new.matches(f)).collect() + files.iter().filter(|&f| new.matches(f)).cloned().collect() }); } new diff --git a/rust/hg-core/src/revlog/changelog.rs b/rust/hg-core/src/revlog/changelog.rs --- a/rust/hg-core/src/revlog/changelog.rs +++ b/rust/hg-core/src/revlog/changelog.rs @@ -617,7 +617,7 @@ message", #[test] fn test_unescape_nul_followed_by_octal() { // Escaped NUL chars followed by octal digits are decoded correctly. - let expected = b"\012"; + let expected = b"\x0012"; let escaped = br"\012"; let unescaped = unescape_extra(escaped); assert_eq!(&expected[..], &unescaped[..]); @@ -713,7 +713,7 @@ message", for (extra, msg) in test_cases { assert!( - decode_extra(&extra).is_err(), + decode_extra(extra).is_err(), "corrupt extra should have failed to parse: {}", msg ); diff --git a/rust/hg-core/src/revlog/index.rs b/rust/hg-core/src/revlog/index.rs --- a/rust/hg-core/src/revlog/index.rs +++ b/rust/hg-core/src/revlog/index.rs @@ -1387,6 +1387,7 @@ trait PoisonableBitSet: Sized + PartialE fn vec_of_empty(sets_size: usize, vec_len: usize) -> Vec; /// The size of the bit mask in memory + #[allow(unused)] fn size(&self) -> usize; /// The number of elements that can be represented in the set. @@ -1394,12 +1395,14 @@ trait PoisonableBitSet: Sized + PartialE /// Another way to put it is that it is the highest integer `C` such that /// the set is guaranteed to always be a subset of the integer range /// `[0, C)` + #[allow(unused)] fn capacity(&self) -> usize; /// Declare `n` to belong to the set fn add(&mut self, n: usize); /// Declare `n` not to belong to the set + #[allow(unused)] fn discard(&mut self, n: usize); /// Replace this bit set by its union with other @@ -1749,6 +1752,9 @@ impl<'a> IndexEntry<'a> { } #[cfg(test)] +pub use tests::IndexEntryBuilder; + +#[cfg(test)] mod tests { use super::*; use crate::node::NULL_NODE; @@ -2027,6 +2033,3 @@ mod tests { assert_eq!(get_version(&bytes), 2) } } - -#[cfg(test)] -pub use tests::IndexEntryBuilder; diff --git a/rust/hg-core/src/revlog/node.rs b/rust/hg-core/src/revlog/node.rs --- a/rust/hg-core/src/revlog/node.rs +++ b/rust/hg-core/src/revlog/node.rs @@ -83,7 +83,7 @@ impl<'a> TryFrom<&'a [u8]> for &'a Node #[inline] fn try_from(bytes: &'a [u8]) -> Result { match Node::from_bytes(bytes) { - Ok((node, rest)) if rest.is_empty() => Ok(node), + Ok((node, [])) => Ok(node), _ => Err(()), } } @@ -323,6 +323,9 @@ impl PartialEq for NodePrefix { } #[cfg(test)] +pub use tests::hex_pad_right; + +#[cfg(test)] mod tests { use super::*; @@ -428,6 +431,3 @@ mod tests { assert_eq!(prefix.first_different_nybble(&node), None); } } - -#[cfg(test)] -pub use tests::hex_pad_right; diff --git a/rust/hg-core/tests/test_missing_ancestors.rs b/rust/hg-core/tests/test_missing_ancestors.rs --- a/rust/hg-core/tests/test_missing_ancestors.rs +++ b/rust/hg-core/tests/test_missing_ancestors.rs @@ -69,6 +69,7 @@ fn ancestors_sets(vg: &VecGraph) -> Vec< ancs } +#[allow(unused)] // Useful when debugging #[derive(Clone, Debug)] enum MissingAncestorsAction { InitialBases(HashSet),