Mercurial > public > mercurial-scm > hg
diff rust/hg-core/src/ancestors.rs @ 49930:e98fd81bb151
rust-clippy: fix most warnings in `hg-core`
All of these are simple changes that for the most part are clear improvements
and the rest are at most equivalent.
The remaining warnings have to be fixed either with a bigger refactor like for
the nested "revlog" module, or in the dependency `bytes-cast`, which we own.
This will be done sometime in the future.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 09 Jan 2023 19:18:43 +0100 |
parents | c7fb9b74e753 |
children | 4c5f6e95df84 |
line wrap: on
line diff
--- a/rust/hg-core/src/ancestors.rs Mon Jan 09 19:14:14 2023 +0100 +++ b/rust/hg-core/src/ancestors.rs Mon Jan 09 19:18:43 2023 +0100 @@ -175,7 +175,7 @@ /// /// This is useful in unit tests, but also setdiscovery.py does /// read the bases attribute of a ancestor.missingancestors instance. - pub fn get_bases<'a>(&'a self) -> &'a HashSet<Revision> { + pub fn get_bases(&self) -> &HashSet<Revision> { &self.bases } @@ -288,7 +288,7 @@ .collect(); let revs_visit = &mut revs; let mut both_visit: HashSet<Revision> = - revs_visit.intersection(&bases_visit).cloned().collect(); + revs_visit.intersection(bases_visit).cloned().collect(); if revs_visit.is_empty() { return Ok(Vec::new()); } @@ -503,18 +503,18 @@ MissingAncestors::new(SampleGraph, [5, 3, 1, 3].iter().cloned()); let mut as_vec: Vec<Revision> = missing_ancestors.get_bases().iter().cloned().collect(); - as_vec.sort(); + as_vec.sort_unstable(); assert_eq!(as_vec, [1, 3, 5]); assert_eq!(missing_ancestors.max_base, 5); missing_ancestors.add_bases([3, 7, 8].iter().cloned()); as_vec = missing_ancestors.get_bases().iter().cloned().collect(); - as_vec.sort(); + as_vec.sort_unstable(); assert_eq!(as_vec, [1, 3, 5, 7, 8]); assert_eq!(missing_ancestors.max_base, 8); as_vec = missing_ancestors.bases_heads()?.iter().cloned().collect(); - as_vec.sort(); + as_vec.sort_unstable(); assert_eq!(as_vec, [3, 5, 7, 8]); Ok(()) } @@ -531,7 +531,7 @@ .remove_ancestors_from(&mut revset) .unwrap(); let mut as_vec: Vec<Revision> = revset.into_iter().collect(); - as_vec.sort(); + as_vec.sort_unstable(); assert_eq!(as_vec.as_slice(), expected); } @@ -572,6 +572,7 @@ /// the one in test-ancestor.py. An early version of Rust MissingAncestors /// failed this, yet none of the integration tests of the whole suite /// catched it. + #[allow(clippy::unnecessary_cast)] #[test] fn test_remove_ancestors_from_case1() { let graph: VecGraph = vec![