diff --git a/components/butterfly/src/rumor.rs b/components/butterfly/src/rumor.rs index f6d59bb371..fcd94b2f6e 100644 --- a/components/butterfly/src/rumor.rs +++ b/components/butterfly/src/rumor.rs @@ -311,8 +311,7 @@ mod storage { /// * `RumorStore::list` (write) pub fn insert_rsw(&self, rumor: R) -> bool { let mut list = self.list.write(); - let rumors = list.entry(String::from(rumor.key())) - .or_insert_with(HashMap::new); + let rumors = list.entry(String::from(rumor.key())).or_default(); let kind_ignored_count = IGNORED_RUMOR_COUNT.with_label_values(&[&rumor.kind().to_string()]); // Result reveals if there was a change so we can increment the counter if needed. diff --git a/components/butterfly/src/rumor/departure.rs b/components/butterfly/src/rumor/departure.rs index 362e0f4478..9fe39edfcf 100644 --- a/components/butterfly/src/rumor/departure.rs +++ b/components/butterfly/src/rumor/departure.rs @@ -117,11 +117,10 @@ mod tests { } #[test] - #[should_panic(expected = "assertion failed")] fn departures_with_different_member_ids_are_not_equal() { let s1 = create_departure("mastodon"); let s2 = create_departure("limpbizkit"); - assert_eq!(s1, s2); + assert_ne!(s1, s2); } // Order diff --git a/components/butterfly/src/rumor/service.rs b/components/butterfly/src/rumor/service.rs index 693ecd4995..8ce96f8ed6 100644 --- a/components/butterfly/src/rumor/service.rs +++ b/components/butterfly/src/rumor/service.rs @@ -254,29 +254,26 @@ mod tests { } #[test] - #[should_panic(expected = "assertion failed")] fn services_with_different_member_ids_are_not_equal() { let s1 = create_service("adam"); let s2 = create_service("shanku"); - assert_eq!(s1, s2); + assert_ne!(s1, s2); } #[test] - #[should_panic(expected = "assertion failed")] fn services_with_different_incarnations_are_not_equal() { let s1 = create_service("adam"); let mut s2 = create_service("adam"); s2.incarnation = 1; - assert_eq!(s1, s2); + assert_ne!(s1, s2); } #[test] - #[should_panic(expected = "assertion failed")] fn services_with_different_service_groups_are_not_equal() { let s1 = create_service("adam"); let mut s2 = create_service("adam"); s2.service_group = ServiceGroup::from_str("adam.fragile").unwrap(); - assert_eq!(s1, s2); + assert_ne!(s1, s2); } // Order diff --git a/components/butterfly/src/rumor/service_config.rs b/components/butterfly/src/rumor/service_config.rs index 36e2ffd47e..3533d80a2e 100644 --- a/components/butterfly/src/rumor/service_config.rs +++ b/components/butterfly/src/rumor/service_config.rs @@ -198,21 +198,19 @@ mod tests { } #[test] - #[should_panic(expected = "assertion failed")] fn service_configs_with_different_incarnations_are_not_equal() { let s1 = create_service_config("adam", "yep"); let mut s2 = create_service_config("adam", "yep"); s2.incarnation = 1; - assert_eq!(s1, s2); + assert_ne!(s1, s2); } #[test] - #[should_panic(expected = "assertion failed")] fn service_configs_with_different_service_groups_are_not_equal() { let s1 = create_service_config("adam", "yep"); let mut s2 = create_service_config("adam", "yep"); s2.service_group = ServiceGroup::from_str("adam.fragile").unwrap(); - assert_eq!(s1, s2); + assert_ne!(s1, s2); } // Order diff --git a/components/butterfly/src/rumor/service_file.rs b/components/butterfly/src/rumor/service_file.rs index 9267b3cc70..7cf50bc1a2 100644 --- a/components/butterfly/src/rumor/service_file.rs +++ b/components/butterfly/src/rumor/service_file.rs @@ -172,21 +172,19 @@ mod tests { } #[test] - #[should_panic(expected = "assertion failed")] fn service_files_with_different_incarnations_are_not_equal() { let s1 = create_service_file("adam", "yep", "tcp-backlog = 128"); let mut s2 = create_service_file("adam", "yep", "tcp-backlog = 128"); s2.incarnation = 1; - assert_eq!(s1, s2); + assert_ne!(s1, s2); } #[test] - #[should_panic(expected = "assertion failed")] fn service_files_with_different_service_groups_are_not_equal() { let s1 = create_service_file("adam", "yep", "tcp-backlog = 128"); let mut s2 = create_service_file("adam", "yep", "tcp-backlog = 128"); s2.service_group = ServiceGroup::from_str("adam.fragile").unwrap(); - assert_eq!(s1, s2); + assert_ne!(s1, s2); } // Order diff --git a/components/common/src/package_graph.rs b/components/common/src/package_graph.rs index f3895e0ae1..f5844e1f27 100644 --- a/components/common/src/package_graph.rs +++ b/components/common/src/package_graph.rs @@ -76,7 +76,7 @@ impl PackageGraph { for dep in deps { let dep_idx = self.node_idx(dep); - self.graph.extend_with_edges(&[(idx, dep_idx)]); + self.graph.extend_with_edges([(idx, dep_idx)]); } assert_eq!(self.graph.node_count(), self.nodes.len()); diff --git a/components/common/src/templating/config.rs b/components/common/src/templating/config.rs index 284186bdf0..2837c24198 100644 --- a/components/common/src/templating/config.rs +++ b/components/common/src/templating/config.rs @@ -1094,9 +1094,9 @@ mod test { fs::create_dir_all(&dir_a).expect("create dir_a"); fs::create_dir_all(&dir_c).expect("create dir_b and dir_c"); - create_with_content(&dir_a.join("foo.txt"), "Hello world!"); - create_with_content(&dir_b.join("bar.txt"), "Hello world!"); - create_with_content(&dir_c.join("baz.txt"), "Hello world!"); + create_with_content(dir_a.join("foo.txt"), "Hello world!"); + create_with_content(dir_b.join("bar.txt"), "Hello world!"); + create_with_content(dir_c.join("baz.txt"), "Hello world!"); let renderer = load_templates(&input_dir, &PathBuf::new(), TemplateRenderer::new()) .expect("visit config dirs"); diff --git a/components/core/src/crypto/keys/ring_key.rs b/components/core/src/crypto/keys/ring_key.rs index febb6fe6fe..bf3fbdfd3b 100644 --- a/components/core/src/crypto/keys/ring_key.rs +++ b/components/core/src/crypto/keys/ring_key.rs @@ -7,8 +7,7 @@ use crate::{crypto::{keys::NamedRevision, /// Private module to re-export the various sodiumoxide concepts we /// use, to keep them all consolidated and abstracted. mod primitives { - pub use sodiumoxide::crypto::secretbox::{self, - gen_key, + pub use sodiumoxide::crypto::secretbox::{gen_key, gen_nonce, open, seal, diff --git a/components/core/src/crypto/keys/signing.rs b/components/core/src/crypto/keys/signing.rs index 93571f4fb2..dbb5aee4ef 100644 --- a/components/core/src/crypto/keys/signing.rs +++ b/components/core/src/crypto/keys/signing.rs @@ -143,7 +143,7 @@ mod tests { let key: SecretOriginSigningKey = fixture_key("keys/origin-key-valid-20160509190508.sig.key"); let file_to_sign = fixture("signme.dat"); - let signed_message = key.sign(&file_to_sign).unwrap(); + let signed_message = key.sign(file_to_sign).unwrap(); let expected = SIGNED_SIGNME_DAT_BLAKE2B_HASH.to_vec(); assert_eq!(signed_message.len(), expected.len()); diff --git a/components/core/src/package/ident.rs b/components/core/src/package/ident.rs index 3da80e0183..13896aa240 100644 --- a/components/core/src/package/ident.rs +++ b/components/core/src/package/ident.rs @@ -231,6 +231,7 @@ impl PartialOrd for PackageIdent { /// * If the names are not equal, they cannot be compared. /// * If the versions are greater/lesser, return that as the ordering. /// * If the versions are equal, return the greater/lesser for the release. + #[allow(clippy::non_canonical_partial_ord_impl)] fn partial_cmp(&self, other: &PackageIdent) -> Option { if self.name != other.name { return None; diff --git a/components/core/src/package/install.rs b/components/core/src/package/install.rs index dadbb01c6d..53b170c744 100644 --- a/components/core/src/package/install.rs +++ b/components/core/src/package/install.rs @@ -506,9 +506,7 @@ impl PackageInstall { paths.push(p); } - let ordered_pkgs = self.load_deps()? - .into_iter() - .chain(self.load_tdeps()?.into_iter()); + let ordered_pkgs = self.load_deps()?.into_iter().chain(self.load_tdeps()?); for pkg in ordered_pkgs { for p in pkg.paths()? { if seen.contains(&p) { @@ -1091,7 +1089,7 @@ mod test { &pkg_install, MetaFile::Path, env::join_paths( - vec![ + [ pkg_prefix_for(&pkg_install).join("bin"), pkg_prefix_for(&other_pkg_install).join("bin"), pkg_prefix_for(&other_pkg_install).join("sbin"), @@ -1117,9 +1115,9 @@ mod test { // Create `RUNTIME_ENVIROMENT` metafile which has path entries from another package to // replicate certain older packages let path_val = - env::join_paths(vec![pkg_prefix_for(&pkg_install).join("bin"), - pkg_prefix_for(&other_pkg_install).join("bin"), - pkg_prefix_for(&other_pkg_install).join("sbin"),].iter()).unwrap(); + env::join_paths([pkg_prefix_for(&pkg_install).join("bin"), + pkg_prefix_for(&other_pkg_install).join("bin"), + pkg_prefix_for(&other_pkg_install).join("sbin")].iter()).unwrap(); write_metafile(&pkg_install, MetaFile::RuntimeEnvironment, &format!("PATH={}\n", path_val.to_string_lossy().as_ref())); diff --git a/components/hab/src/command/bldr/job/promote.rs b/components/hab/src/command/bldr/job/promote.rs index c3f0c3c525..b852c1007e 100644 --- a/components/hab/src/command/bldr/job/promote.rs +++ b/components/hab/src/command/bldr/job/promote.rs @@ -26,8 +26,8 @@ pub fn get_ident_list(ui: &mut UI, let mut idents: Vec = group_status.projects .iter() + .filter(|&p| p.state == "Success" && in_origin(&p.ident, origin)) .cloned() - .filter(|p| p.state == "Success" && in_origin(&p.ident, origin)) .map(|p| p.ident) .collect(); diff --git a/components/hab/src/command/studio/docker.rs b/components/hab/src/command/studio/docker.rs index b8dae7b8be..cbe6788e84 100644 --- a/components/hab/src/command/studio/docker.rs +++ b/components/hab/src/command/studio/docker.rs @@ -35,7 +35,7 @@ const HAB_STUDIO_SECRET: &str = "HAB_STUDIO_SECRET_"; pub fn start_docker_studio(_ui: &mut UI, args: &[OsString]) -> Result<()> { let mut args = args.to_vec(); - if args.get(0) == Some(&OsString::from("rm")) { + if args.first() == Some(&OsString::from("rm")) { return Err(Error::CannotRemoveDockerStudio); } diff --git a/components/launcher/src/sys/windows/service.rs b/components/launcher/src/sys/windows/service.rs index b180cc2f3b..d15b7488c2 100644 --- a/components/launcher/src/sys/windows/service.rs +++ b/components/launcher/src/sys/windows/service.rs @@ -192,8 +192,7 @@ fn build_proc_table() -> ProcessTable { let mut process_success: i32 = 1; // Loop through all processes until we find one where `szExeFile` == `name`. while process_success == 1 { - let children = table.entry(process_entry.th32ParentProcessID) - .or_insert_with(Vec::new); + let children = table.entry(process_entry.th32ParentProcessID).or_default(); (*children).push(process_entry.th32ProcessID); process_success = unsafe { tlhelp32::Process32NextW(processes_snap_handle, &mut process_entry) }; diff --git a/components/sup/src/census.rs b/components/sup/src/census.rs index 5b360b067e..a5fb31bab8 100644 --- a/components/sup/src/census.rs +++ b/components/sup/src/census.rs @@ -497,9 +497,7 @@ impl CensusGroup { self.changed_service_files.clear(); for (_m_id, service_file_rumor) in service_file_rumors.iter() { let filename = service_file_rumor.filename.to_string(); - let file = self.service_files - .entry(filename.clone()) - .or_insert_with(ServiceFile::default); + let file = self.service_files.entry(filename.clone()).or_default(); if service_file_rumor.incarnation > file.incarnation { match service_file_rumor.body(key_cache) { diff --git a/components/sup/src/manager/peer_watcher.rs b/components/sup/src/manager/peer_watcher.rs index d822f965a9..a5111a8692 100644 --- a/components/sup/src/manager/peer_watcher.rs +++ b/components/sup/src/manager/peer_watcher.rs @@ -212,7 +212,7 @@ mod tests { lock.unset(); let mut members = peer_watcher_member_load_test(tmpdir.path(), &peer_lines).unwrap(); - for mut member in &mut members { + for member in &mut members { member.id = String::new(); } let member1 = Member { id: String::new(), @@ -237,7 +237,7 @@ mod tests { lock.set("aarch64-darwin"); let mut members = peer_watcher_member_load_test(tmpdir.path(), &peer_lines).unwrap(); lock.unset(); - for mut member in &mut members { + for member in &mut members { member.id = String::new(); } let member1 = Member { id: String::new(), diff --git a/components/sup/src/manager/service.rs b/components/sup/src/manager/service.rs index 60c7354239..9d4ebf5209 100644 --- a/components/sup/src/manager/service.rs +++ b/components/sup/src/manager/service.rs @@ -1683,7 +1683,7 @@ impl From<&ServiceQueryModel> for habitat_sup_protocol::types::ServiceStatus { } #[cfg(test)] -#[cfg(any(all(target_os = "linux", any(target_arch = "x86_64")), +#[cfg(any(all(target_os = "linux", target_arch = "x86_64"), all(target_os = "windows", target_arch = "x86_64"),))] mod tests { use super::*; diff --git a/components/sup/src/manager/service/supervisor.rs b/components/sup/src/manager/service/supervisor.rs index a5c1b53a1b..62317f9eb3 100644 --- a/components/sup/src/manager/service/supervisor.rs +++ b/components/sup/src/manager/service/supervisor.rs @@ -423,7 +423,7 @@ fn read_pid(pid_file: T) -> Option match reader.lines().next() { Some(Ok(line)) => { match line.parse::() { - Ok(pid) if pid == 0 => { + Ok(0) => { error!(target: "pidfile_tracing", "Read PID of 0 from {}!", p.display()); // Treat this the same as a corrupt pid // file, because that's basically what it diff --git a/components/sup/src/sys/windows/service.rs b/components/sup/src/sys/windows/service.rs index 579f8dd286..ef28fc5a7f 100644 --- a/components/sup/src/sys/windows/service.rs +++ b/components/sup/src/sys/windows/service.rs @@ -137,8 +137,7 @@ fn build_proc_table() -> ProcessTable { let mut process_success: i32 = 1; // Loop through all processes until we find one where `szExeFile` == `name`. while process_success == 1 { - let children = table.entry(process_entry.th32ParentProcessID) - .or_insert_with(Vec::new); + let children = table.entry(process_entry.th32ParentProcessID).or_default(); (*children).push(process_entry.th32ProcessID); process_success = unsafe { tlhelp32::Process32NextW(processes_snap_handle, &mut process_entry) }; diff --git a/components/sup/tests/utils/mod.rs b/components/sup/tests/utils/mod.rs index 1c1d0e8a11..8e9c4555ef 100644 --- a/components/sup/tests/utils/mod.rs +++ b/components/sup/tests/utils/mod.rs @@ -8,9 +8,7 @@ pub mod test_sup; // Re-export the key structs of this package for ergonomics. pub use self::{fixture_root::FixtureRoot, - fs::{copy_dir, - setup_package_files, - FileSnapshot, + fs::{setup_package_files, FileSystemSnapshot}, hab_root::HabRoot, test_sup::TestSup}; diff --git a/rust-toolchain b/rust-toolchain index 864d3c411a..7897a24d1a 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,2 +1,2 @@ [toolchain] -channel = "1.68.2" +channel = "1.75.0"