From 4fd60bd63e7568f534a605341dca2f32aa01f502 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Tue, 18 Mar 2025 07:41:23 -0700 Subject: [PATCH] bump rust to 1.85.0 Signed-off-by: Matt Wrock --- .expeditor/scripts/verify/run_cargo_test.sh | 12 +++--- .expeditor/scripts/verify/run_clippy.sh | 8 ++-- .expeditor/scripts/verify/shared.sh | 2 +- .expeditor/verify.pipeline.yml | 2 +- components/builder-api-client/src/builder.rs | 1 + components/butterfly/build.rs | 1 - components/butterfly/src/member.rs | 6 +-- components/butterfly/src/rumor.rs | 20 +++++----- components/butterfly/src/server.rs | 4 +- components/butterfly/src/server/outbound.rs | 4 +- components/butterfly/tests/common/mod.rs | 7 +--- .../common/src/command/package/install.rs | 3 +- components/common/src/lib.rs | 11 +++--- components/common/src/output.rs | 4 +- components/common/src/owning_refs.rs | 6 +-- components/common/src/templating/config.rs | 4 +- components/common/src/templating/context.rs | 2 +- components/common/src/templating/hooks.rs | 6 +-- components/core/src/crypto.rs | 37 ++++++++++--------- components/core/src/fs.rs | 4 +- .../core/src/os/process/windows_child.rs | 2 +- components/core/src/package/ident.rs | 2 +- components/core/src/package/target.rs | 6 +-- components/core/src/service.rs | 2 +- components/core/src/util/posix_perm.rs | 5 +-- components/hab/Cargo.toml | 1 + components/hab/src/command/cli/setup.rs | 4 +- .../hab/src/command/origin/key/download.rs | 4 +- components/hab/src/command/pkg/download.rs | 3 +- .../src/command/pkg/export/export_common.rs | 2 +- components/hab/src/command/plan/init.rs | 2 +- components/hab/src/command/studio/enter.rs | 2 +- components/hab/src/scaffolding.rs | 18 ++++----- components/launcher-protocol/build.rs | 1 - components/launcher/src/server.rs | 2 +- components/pkg-export-container/src/build.rs | 7 ++-- components/sup-protocol/build.rs | 1 - components/sup/src/census.rs | 4 +- components/sup/src/lib.rs | 8 ++-- components/sup/src/lock_file.rs | 22 +++++------ components/sup/src/manager.rs | 10 ++--- components/sup/src/manager/service.rs | 2 +- components/sup/src/manager/service/context.rs | 4 +- rust-toolchain | 2 +- 44 files changed, 128 insertions(+), 132 deletions(-) diff --git a/.expeditor/scripts/verify/run_cargo_test.sh b/.expeditor/scripts/verify/run_cargo_test.sh index c1dbcebbc1..5263752a27 100755 --- a/.expeditor/scripts/verify/run_cargo_test.sh +++ b/.expeditor/scripts/verify/run_cargo_test.sh @@ -21,15 +21,17 @@ if ${BUILDKITE:-false}; then fi # TODO: these should be in a shared script? -sudo hab pkg install core/zeromq -sudo hab pkg install core/protobuf -sudo hab pkg install core/rust/"$toolchain" +sudo -E hab pkg install core/zeromq +sudo -E hab pkg install core/protobuf +sudo -E hab pkg install core/rust/"$toolchain" export LIBZMQ_PREFIX LIBZMQ_PREFIX=$(hab pkg path core/zeromq) # now include zeromq and gcc so they exist in the runtime library path when cargo test is run export LD_LIBRARY_PATH -LD_LIBRARY_PATH="$(hab pkg path core/gcc)/lib:$(hab pkg path core/zeromq)/lib" -eval "$(hab pkg env core/rust/"$toolchain"):$PATH" +LD_LIBRARY_PATH="$(hab pkg path core/gcc-base)/lib64:$(hab pkg path core/zeromq)/lib" +old_path=$PATH +eval "$(hab pkg env core/rust/"$toolchain")" +export PATH=$PATH:$old_path export PROTOC_NO_VENDOR=1 export PROTOC diff --git a/.expeditor/scripts/verify/run_clippy.sh b/.expeditor/scripts/verify/run_clippy.sh index 0a24eede3c..97c6d51f46 100755 --- a/.expeditor/scripts/verify/run_clippy.sh +++ b/.expeditor/scripts/verify/run_clippy.sh @@ -16,7 +16,7 @@ rustup component add --toolchain "$toolchain" clippy # TODO: these should be in a shared script? install_hab_pkg core/zeromq core/protobuf core/patchelf -sudo hab pkg install core/rust/"$toolchain" +sudo -E hab pkg install core/rust/"$toolchain" # Yes, this is terrible but we need the clippy binary to run under our glibc. # This became an issue with the latest refresh and can likely be dropped in @@ -31,8 +31,10 @@ export LIBZMQ_PREFIX LIBZMQ_PREFIX=$(hab pkg path core/zeromq) # now include zeromq so it exists in the runtime library path when cargo test is run export LD_LIBRARY_PATH -LD_LIBRARY_PATH="$(hab pkg path core/gcc)/lib:$(hab pkg path core/zeromq)/lib" -eval "$(hab pkg env core/rust/"$toolchain"):$PATH" +LD_LIBRARY_PATH="$(hab pkg path core/gcc-base)/lib64:$(hab pkg path core/zeromq)/lib" +old_path=$PATH +eval "$(hab pkg env core/rust/"$toolchain")" +export PATH=$PATH:$old_path export PROTOC_NO_VENDOR=1 export PROTOC diff --git a/.expeditor/scripts/verify/shared.sh b/.expeditor/scripts/verify/shared.sh index c6cc32b213..92c0730d32 100755 --- a/.expeditor/scripts/verify/shared.sh +++ b/.expeditor/scripts/verify/shared.sh @@ -51,7 +51,7 @@ install_hab_pkg() { installed_pkgs=$(hab pkg list "$ident") if [[ -z $installed_pkgs ]]; then - sudo hab pkg install "$ident" + sudo -E hab pkg install "$ident" else echo "$ident already installed" fi diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index a7c7d9800a..4bc52f11ad 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -194,7 +194,7 @@ steps: - label: "[unit] :linux: common" command: - - .expeditor/scripts/verify/run_cargo_test.sh common + - HAB_BLDR_CHANNEL=LTS-2024 .expeditor/scripts/verify/run_cargo_test.sh common agents: queue: 'default-privileged' plugins: diff --git a/components/builder-api-client/src/builder.rs b/components/builder-api-client/src/builder.rs index 963af9ae16..06e9a230c0 100644 --- a/components/builder-api-client/src/builder.rs +++ b/components/builder-api-client/src/builder.rs @@ -1581,6 +1581,7 @@ mod tests { release: None, } } + #[allow(clippy::type_complexity)] fn seach_generator<'a>( data: &'a [&str], step: usize) diff --git a/components/butterfly/build.rs b/components/butterfly/build.rs index d558b87cac..af3e2e0b3e 100644 --- a/components/butterfly/build.rs +++ b/components/butterfly/build.rs @@ -3,7 +3,6 @@ /// /// Generated code is deposited in `OUT_DIR` and automatically /// `include!`-ed in our Rust modules, per standard Prost practice. - fn main() { let mut config = prost_build::Config::new(); config.type_attribute(".butterfly.newscast.Rumor.payload", diff --git a/components/butterfly/src/member.rs b/components/butterfly/src/member.rs index 75f458ac1e..4120e37f30 100644 --- a/components/butterfly/src/member.rs +++ b/components/butterfly/src/member.rs @@ -101,7 +101,7 @@ impl FromStr for Incarnation { struct IncarnationVisitor; -impl<'de> de::Visitor<'de> for IncarnationVisitor { +impl de::Visitor<'_> for IncarnationVisitor { type Value = Incarnation; fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -850,7 +850,7 @@ impl<'a> MemberListProxy<'a> { pub fn new(m: &'a MemberList) -> Self { MemberListProxy(m) } } -impl<'a> Serialize for MemberListProxy<'a> { +impl Serialize for MemberListProxy<'_> { /// # Locking (see locking.md) /// * `MemberList::entries` (read) fn serialize(&self, serializer: S) -> result::Result @@ -876,7 +876,7 @@ impl<'a> MemberProxy<'a> { pub fn new(m: &'a Member, h: &'a Health) -> Self { MemberProxy(m, h) } } -impl<'a> Serialize for MemberProxy<'a> { +impl Serialize for MemberProxy<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { diff --git a/components/butterfly/src/rumor.rs b/components/butterfly/src/rumor.rs index 23ed18d6e6..ea8f4b3895 100644 --- a/components/butterfly/src/rumor.rs +++ b/components/butterfly/src/rumor.rs @@ -158,7 +158,7 @@ mod storage { /// lifetime of the service group key. pub struct ServiceGroupRumors<'sg_key, R>(Option<&'sg_key RumorSubMap>); - impl<'sg_key, R> ServiceGroupRumors<'sg_key, R> { + impl ServiceGroupRumors<'_, R> { /// Allows iterator access to the rumors in a particular service group: /// ``` /// # use habitat_butterfly::rumor::{RumorStore, @@ -219,7 +219,7 @@ mod storage { } } - impl<'a, R: Rumor> IterableGuard<'a, RumorMap> { + impl IterableGuard<'_, RumorMap> { pub fn contains_rumor(&self, rumor: &R) -> bool { let RumorKey { key, id, .. } = rumor.into(); @@ -238,7 +238,7 @@ mod storage { } } - impl<'a, C: ConstKeyRumor> IterableGuard<'a, RumorMap> { + impl IterableGuard<'_, RumorMap> { pub fn contains_id(&self, member_id: &str) -> bool { self.get(C::const_key()) .map(|rumors| rumors.contains_key(member_id)) @@ -246,7 +246,7 @@ mod storage { } } - impl<'a, E: ElectionRumor> IterableGuard<'a, RumorMap> { + impl IterableGuard<'_, RumorMap> { pub fn get_term(&self, service_group: &str) -> Option { self.get(service_group) .map(|sg| sg.get(E::const_id()).map(ElectionRumor::term)) @@ -254,7 +254,7 @@ mod storage { } } - impl<'a, E: ElectionRumor> IterableGuard<'a, RumorMap> { + impl IterableGuard<'_, RumorMap> { pub fn get_member_id(&self, service_group: &str) -> Option<&str> { self.get(service_group) .map(|sg| sg.get(E::const_id()).map(ElectionRumor::member_id)) @@ -269,7 +269,7 @@ mod storage { /// let rs: RumorStore = RumorStore::default(); /// assert_eq!(rs.lock_rsr().len(), 0); /// ``` - impl<'a, R> std::ops::Deref for IterableGuard<'a, RumorMap> { + impl std::ops::Deref for IterableGuard<'_, RumorMap> { type Target = RumorMap; fn deref(&self) -> &Self::Target { &self.0 } @@ -374,7 +374,7 @@ mod storage { pub fn new(r: &'a RumorStore) -> Self { RumorStoreProxy(r) } } - impl<'a> Serialize for RumorStoreProxy<'a, Departure> { + impl Serialize for RumorStoreProxy<'_, Departure> { /// # Locking (see locking.md) /// * `RumorStore::list` (read) fn serialize(&self, serializer: S) -> result::Result @@ -395,7 +395,7 @@ mod storage { } } - impl<'a, C: ConstIdRumor> Serialize for RumorStoreProxy<'a, C> { + impl Serialize for RumorStoreProxy<'_, C> { /// # Locking (see locking.md) /// * `RumorStore::list` (read) fn serialize(&self, serializer: S) -> result::Result @@ -419,7 +419,7 @@ mod storage { } } - impl<'a> Serialize for RumorStoreProxy<'a, Service> { + impl Serialize for RumorStoreProxy<'_, Service> { /// # Locking (see locking.md) /// * `RumorStore::list` (read) fn serialize(&self, serializer: S) -> result::Result @@ -436,7 +436,7 @@ mod storage { } } - impl<'a> Serialize for RumorStoreProxy<'a, ServiceFile> { + impl Serialize for RumorStoreProxy<'_, ServiceFile> { /// # Locking (see locking.md) /// * `RumorStore::list` (read) fn serialize(&self, serializer: S) -> result::Result diff --git a/components/butterfly/src/server.rs b/components/butterfly/src/server.rs index eee60d1a9d..447ed77ffd 100644 --- a/components/butterfly/src/server.rs +++ b/components/butterfly/src/server.rs @@ -790,7 +790,7 @@ impl Server { let inserting_new_group_member = service_store.lock_rsr() .get(service_group) - .map_or(false, |rumors| !rumors.contains_key(member_id)); + .is_some_and(|rumors| !rumors.contains_key(member_id)); if service_store.insert_rsw(service) { if inserting_new_group_member && !check_quorum(service_group) { @@ -1437,7 +1437,7 @@ impl<'a> ServerProxy<'a> { pub fn new(s: &'a Server) -> Self { ServerProxy(s) } } -impl<'a> Serialize for ServerProxy<'a> { +impl Serialize for ServerProxy<'_> { /// # Locking (see locking.md) /// * `MemberList::entries` (read) /// * `RumorStore::list` (read) diff --git a/components/butterfly/src/server/outbound.rs b/components/butterfly/src/server/outbound.rs index 3ef469c0d5..5d385d7e3c 100644 --- a/components/butterfly/src/server/outbound.rs +++ b/components/butterfly/src/server/outbound.rs @@ -537,8 +537,8 @@ pub fn ack_mlr_smr_rhw(server: &Server, addr: SocketAddr, forward_to: Option) { let ack_msg = Ack { membership: vec![], - from: server.myself.lock_smr().to_member(), - forward_to: forward_to.map(Member::from), }; + from: server.myself.lock_smr().to_member(), + forward_to }; let swim = populate_membership_rumors_mlr_rhw(server, target, ack_msg); let bytes = match swim.encode() { Ok(bytes) => bytes, diff --git a/components/butterfly/tests/common/mod.rs b/components/butterfly/tests/common/mod.rs index 3c11d2dd62..c17cf303ed 100644 --- a/components/butterfly/tests/common/mod.rs +++ b/components/butterfly/tests/common/mod.rs @@ -423,11 +423,8 @@ impl SwimNet { return true; } else if self.check_rounds(&rounds_in) { for (i, some_health) in network_health.iter().enumerate() { - match some_health { - Some(ref health) => { - println!("{}: {:?}", i, health); - } - None => {} + if let Some(ref health) = some_health { + println!("{}: {:?}", i, health); } } return false; diff --git a/components/common/src/command/package/install.rs b/components/common/src/command/package/install.rs index 7282ae455f..1c2cc79ac8 100644 --- a/components/common/src/command/package/install.rs +++ b/components/common/src/command/package/install.rs @@ -288,7 +288,6 @@ impl Default for LocalPackageUsage { /// /// At the end of this function, the specified package and all its /// dependencies will be installed on the system. - // TODO (CM): Consider passing in a configured depot client instead of // product / version... That might make it easier to share with the // `sup` crate @@ -426,7 +425,7 @@ struct InstallTask<'a> { install_hook_mode: InstallHookMode, } -impl<'a> InstallTask<'a> { +impl InstallTask<'_> { /// Install a package from the Depot, based on a given identifier. /// /// If the identifier is fully-qualified, that specific package diff --git a/components/common/src/lib.rs b/components/common/src/lib.rs index 5673aeb60d..6ec38fc168 100644 --- a/components/common/src/lib.rs +++ b/components/common/src/lib.rs @@ -117,8 +117,7 @@ impl FeatureFlag { if let Some(val) = env::var_os(env_var) { if !val.is_empty() { flags.insert(*feature); - ui.warn(&format!("Enabling feature: {:?}", feature)) - .unwrap(); + ui.warn(format!("Enabling feature: {:?}", feature)).unwrap(); } } } @@ -135,10 +134,10 @@ impl FeatureFlag { ui.warn("Listing feature flags environment variables:") .unwrap(); for (feature, env_var) in ENV_VARS.iter() { - ui.warn(&format!(" * {:?}: {}={:?}", - feature, - env_var, - env::var_os(env_var).unwrap_or_default())) + ui.warn(format!(" * {:?}: {}={:?}", + feature, + env_var, + env::var_os(env_var).unwrap_or_default())) .unwrap(); } } diff --git a/components/common/src/output.rs b/components/common/src/output.rs index 46173443ea..f4b793dbde 100644 --- a/components/common/src/output.rs +++ b/components/common/src/output.rs @@ -196,7 +196,7 @@ impl<'a> StructuredOutput<'a> { // Custom implementation of Serialize to ensure that we can // appropriately represent both verbose and non-verbose output, a // behavior which isn't otherwise possible to derive. -impl<'a> Serialize for StructuredOutput<'a> { +impl Serialize for StructuredOutput<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { @@ -219,7 +219,7 @@ impl<'a> Serialize for StructuredOutput<'a> { } } -impl<'a> fmt::Display for StructuredOutput<'a> { +impl fmt::Display for StructuredOutput<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let bufwtr = BufferWriter::stdout(self.format.color_choice()); let mut buffer = bufwtr.buffer(); diff --git a/components/common/src/owning_refs.rs b/components/common/src/owning_refs.rs index d0d5dc02f1..43c49c43a4 100644 --- a/components/common/src/owning_refs.rs +++ b/components/common/src/owning_refs.rs @@ -10,7 +10,7 @@ use std::ops::{Deref, // A wrapper around `MutexGuard` needed to implement the `StableAddress` trait to use `OwningRef` pub struct StableMutexGuard<'a, T: ?Sized>(MutexGuard<'a, T>); -unsafe impl<'a, T: ?Sized> StableAddress for StableMutexGuard<'a, T> {} +unsafe impl StableAddress for StableMutexGuard<'_, T> {} impl Deref for StableMutexGuard<'_, T> { type Target = T; @@ -30,7 +30,7 @@ impl<'a, T> From> for StableMutexGuard<'a, T> { // `OwningRef` pub struct StableRwLockReadGuard<'a, T: ?Sized>(RwLockReadGuard<'a, T>); -unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockReadGuard<'a, T> {} +unsafe impl StableAddress for StableRwLockReadGuard<'_, T> {} impl Deref for StableRwLockReadGuard<'_, T> { type Target = T; @@ -46,7 +46,7 @@ impl<'a, T> From> for StableRwLockReadGuard<'a, T> { // `OwningRef` pub struct StableRwLockWriteGuard<'a, T: ?Sized>(RwLockWriteGuard<'a, T>); -unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockWriteGuard<'a, T> {} +unsafe impl StableAddress for StableRwLockWriteGuard<'_, T> {} impl Deref for StableRwLockWriteGuard<'_, T> { type Target = T; diff --git a/components/common/src/templating/config.rs b/components/common/src/templating/config.rs index 35c0769edf..c37e916e76 100644 --- a/components/common/src/templating/config.rs +++ b/components/common/src/templating/config.rs @@ -558,11 +558,11 @@ fn load_templates(dir: &Path, for entry in std::fs::read_dir(dir)?.filter_map(result::Result::ok) { // We're storing the pathname relative to the input config directory // as the identifier for the template - let relative_path = context.join(&entry.file_name()); + let relative_path = context.join(entry.file_name()); match entry.file_type() { Ok(file_type) if file_type.is_file() => { // JW TODO: This error needs improvement. TemplateFileError is too generic. - template.register_template_file(&relative_path.to_string_lossy(), &entry.path()) + template.register_template_file(&relative_path.to_string_lossy(), entry.path()) .map_err(Error::TemplateError)?; } Ok(file_type) if file_type.is_dir() => { diff --git a/components/common/src/templating/context.rs b/components/common/src/templating/context.rs index bae2064fb2..b07dd8762c 100644 --- a/components/common/src/templating/context.rs +++ b/components/common/src/templating/context.rs @@ -133,7 +133,7 @@ impl<'a> Package<'a> { } } -impl<'a> Serialize for Package<'a> { +impl Serialize for Package<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { diff --git a/components/common/src/templating/hooks.rs b/components/common/src/templating/hooks.rs index afca47fea9..9cdaff5f87 100644 --- a/components/common/src/templating/hooks.rs +++ b/components/common/src/templating/hooks.rs @@ -90,7 +90,7 @@ pub trait Hook: fmt::Debug + Sized + Send { .map(|n| template_path.as_ref().join(n)); let has_template = template.exists(); - let has_deprecated_template = deprecated_template.as_ref().map_or(false, |t| t.exists()); + let has_deprecated_template = deprecated_template.as_ref().is_some_and(|t| t.exists()); if has_template && file_name == "reload" { outputln!(preamble package_name, "The '{}' hook has been deprecated. You should use the 'reconfigure' hook instead.", @@ -311,8 +311,8 @@ pub trait PackageMaintenanceHookExt: Hook + Sync { let feature_flags = FeatureFlag::from_env(ui); let package_name = &package.ident.name; if let Some(ref hook) = Self::load(package_name, - &svc_hooks_path(package_name), - &package.installed_path.join("hooks"), + svc_hooks_path(package_name), + package.installed_path.join("hooks"), feature_flags) { let hook_name = Self::FILE_NAME; diff --git a/components/core/src/crypto.rs b/components/core/src/crypto.rs index 6e3ca1b60e..7bf6dfc803 100644 --- a/components/core/src/crypto.rs +++ b/components/core/src/crypto.rs @@ -8,8 +8,8 @@ //! - All public keys, certificates, and signatures are to be referred to as **public**. //! - All secret or private keys are to be referred to as **secret**. //! - All symmetric encryption keys are to be referred to as **secret**. -//! - In general, the word `key` by itself does not indicate something as -//! **public** or **secret**. The exceptions to this rule are as follows: +//! - In general, the word `key` by itself does not indicate something as **public** or **secret**. +//! The exceptions to this rule are as follows: //! - if the word key appears in a URL, then we are referring to a public key to conform to //! other APIs that offer similar public key downloading functionality. //! - the word `key` appears as part of a file suffix, where it is then considered as a **secret @@ -20,29 +20,30 @@ //! - A key name with rev: `habitat-201603312016` //! - A key file: `habitat-201603312016.pub` //! - A key path or fully qualified key path: `/foo/bar/habitat-201603312016.pub` -//! - An **Origin** refers to build-time operations, including signing and verification of a -//! Habitat artifact. +//! - An **Origin** refers to build-time operations, including signing and verification of a Habitat +//! artifact. //! - An **Organization** or **Org** refers to run-time operations such as deploying a package -//! signed in a different origin into your own organization. This is abbreviated as "org" in -//! user-facing command line parameters and internal variable names. -//! - To distinguish between **Org** and **Origin**, the following might help: Habitat packages -//! come from an **Origin** and run in an **Organization**. +//! signed in a different origin into your own organization. This is abbreviated as "org" in +//! user-facing command line parameters and internal variable names. +//! - To distinguish between **Org** and **Origin**, the following might help: Habitat packages come +//! from an **Origin** and run in an **Organization**. //! - A **Ring** is the full set of Supervisors that communicate with each other. //! - A **Signing key**, also known as a **sig** key, is used to sign and verify Habitat artifacts. -//! The file contains a `sig.key` file suffix. Note that sig keys are not compatible with box keys. +//! The file contains a `sig.key` file suffix. Note that sig keys are not compatible with box +//! keys. //! - A **Box key** is used for encryption and decryption of arbitrary data. The file contains a -//! `.box.key` file suffix. Note that box keys are not compatible with sig keys. +//! `.box.key` file suffix. Note that box keys are not compatible with sig keys. //! - A **Sym key** is used for symmetric encryption, meaning that a shared secret is used to -//! encrypt a message into a ciphertext and that same secret is used later to decrypt the ciphertext -//! into the original message. +//! encrypt a message into a ciphertext and that same secret is used later to decrypt the +//! ciphertext into the original message. //! - A **Ring key** is a **sym** key used when sending messages between the Supervisors to prevent -//! a third party from intercepting the traffic. +//! a third party from intercepting the traffic. //! - **Key revisions** - There can exist several keys for any given user, service, ring, or origin -//! via different revision numbers. Revision numbers appear following the key name and are in the -//! format `{year}{month}{day}{hour24}{minute}{second}`. For all user-facing cryptographic -//! operations (such as sign, verify, encrypt, decrypt, etc.), the latest key is tried first, and -//! upon failure, the keys will be tried in reverse chronological order until success or there are -//! no more keys. +//! via different revision numbers. Revision numbers appear following the key name and are in the +//! format `{year}{month}{day}{hour24}{minute}{second}`. For all user-facing cryptographic +//! operations (such as sign, verify, encrypt, decrypt, etc.), the latest key is tried first, and +//! upon failure, the keys will be tried in reverse chronological order until success or there are +//! no more keys. //! //! ***TODO: key revisions are generated as part of a filename, but only the most recent key is //! used during crypto operations.*** diff --git a/components/core/src/fs.rs b/components/core/src/fs.rs index 4f05518622..97c0dfda32 100644 --- a/components/core/src/fs.rs +++ b/components/core/src/fs.rs @@ -557,12 +557,12 @@ impl<'a> SvcDir<'a> { if process::can_run_services_as_svc_user() { posix_perm::set_owner(path.as_ref(), &self.svc_user, &self.svc_group)?; } - posix_perm::set_permissions(path.as_ref(), SVC_DIR_PERMISSIONS).map_err(From::from) + posix_perm::set_permissions(path.as_ref(), SVC_DIR_PERMISSIONS) } #[cfg(windows)] fn set_permissions_and_ownership>(&self, path: T) -> Result<()> { - win_perm::harden_path(path.as_ref()).map_err(From::from) + win_perm::harden_path(path.as_ref()) } } diff --git a/components/core/src/os/process/windows_child.rs b/components/core/src/os/process/windows_child.rs index 1437fd64b5..8dc87db889 100644 --- a/components/core/src/os/process/windows_child.rs +++ b/components/core/src/os/process/windows_child.rs @@ -863,7 +863,7 @@ impl RawHandle { } } -impl<'a> Read for &'a RawHandle { +impl Read for &RawHandle { fn read(&mut self, buf: &mut [u8]) -> io::Result { (**self).read(buf) } fn read_to_end(&mut self, buf: &mut Vec) -> io::Result { diff --git a/components/core/src/package/ident.rs b/components/core/src/package/ident.rs index f05ebf1952..877ec2fd5c 100644 --- a/components/core/src/package/ident.rs +++ b/components/core/src/package/ident.rs @@ -368,7 +368,7 @@ impl TryFrom for FullyQualifiedPackageIdent { } } -impl<'a> TryFrom<&'a PackageIdent> for FullyQualifiedPackageIdent { +impl TryFrom<&PackageIdent> for FullyQualifiedPackageIdent { type Error = Error; fn try_from(ident: &PackageIdent) -> Result { diff --git a/components/core/src/package/target.rs b/components/core/src/package/target.rs index 53e3001b01..17faa115a8 100644 --- a/components/core/src/package/target.rs +++ b/components/core/src/package/target.rs @@ -32,10 +32,10 @@ //! After a package has been built, there are a few ways to check the [`PackageTarget`]: //! //! * Checking an artifact can be done by calling the [`target`][archive_target] method on -//! [`PackageArchive`]. +//! [`PackageArchive`]. //! * Checking that an installed package's target matches the active target is done automatically -//! when calling the [`load`][install_load] or [`load_at_least`][install_load_at_least] functions -//! on [`PackageInstall`]. +//! when calling the [`load`][install_load] or [`load_at_least`][install_load_at_least] functions +//! on [`PackageInstall`]. //! //! # A Special Note Concerning Variants //! diff --git a/components/core/src/service.rs b/components/core/src/service.rs index 9d52c6ca17..150f318c75 100644 --- a/components/core/src/service.rs +++ b/components/core/src/service.rs @@ -117,7 +117,7 @@ impl<'de> serde::Deserialize<'de> for ServiceBind { { struct ServiceBindVisitor; - impl<'de> serde::de::Visitor<'de> for ServiceBindVisitor { + impl serde::de::Visitor<'_> for ServiceBindVisitor { type Value = ServiceBind; fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { diff --git a/components/core/src/util/posix_perm.rs b/components/core/src/util/posix_perm.rs index 61b75632d8..6780dbc703 100644 --- a/components/core/src/util/posix_perm.rs +++ b/components/core/src/util/posix_perm.rs @@ -121,10 +121,7 @@ fn validate_raw_path(path: &str) -> Result<*mut c_char> { } fn chown(path: &str, uid: u32, gid: u32) -> Result { - let r_path = match validate_raw_path(path) { - Ok(r) => r, - Err(e) => return Err(e), - }; + let r_path = validate_raw_path(path)?; unsafe { let res = libc::chown(r_path, uid, gid); diff --git a/components/hab/Cargo.toml b/components/hab/Cargo.toml index 46c0821ecf..175553c31b 100644 --- a/components/hab/Cargo.toml +++ b/components/hab/Cargo.toml @@ -74,3 +74,4 @@ v4 = [ "supported_targets", "clap_v4" ] default = ["supported_targets", "v2"] functional = [] supported_targets = ["habitat_core/supported_targets"] +aarch64-linux = ["habitat_core/aarch64-linux"] diff --git a/components/hab/src/command/cli/setup.rs b/components/hab/src/command/cli/setup.rs index e5f51f8356..18c1d0d120 100644 --- a/components/hab/src/command/cli/setup.rs +++ b/components/hab/src/command/cli/setup.rs @@ -61,7 +61,7 @@ pub fn start(ui: &mut UI, key_cache: &KeyCache) -> Result<()> { while valid_url(&url).is_err() { ui.br()?; - ui.fatal(&format!("{}: is invalid, please provide a valid url", url))?; + ui.fatal(format!("{}: is invalid, please provide a valid url", url))?; ui.br()?; url = prompt_url(ui)?; @@ -93,7 +93,7 @@ pub fn start(ui: &mut UI, key_cache: &KeyCache) -> Result<()> { let mut origin = prompt_origin(ui); while origin.is_err() { ui.br()?; - ui.fatal(&format!("{}", origin.err().unwrap()))?; + ui.fatal(format!("{}", origin.err().unwrap()))?; ui.br()?; origin = prompt_origin(ui); diff --git a/components/hab/src/command/origin/key/download.rs b/components/hab/src/command/origin/key/download.rs index 95da1fcaec..95537af7a5 100644 --- a/components/hab/src/command/origin/key/download.rs +++ b/components/hab/src/command/origin/key/download.rs @@ -171,7 +171,7 @@ async fn download_key(ui: &mut UI, -> Result<()> { if key_cache.public_signing_key(named_revision).is_ok() { ui.status(Status::Using, - &format!("{} in {}", named_revision, key_cache.as_ref().display()))?; + format!("{} in {}", named_revision, key_cache.as_ref().display()))?; Ok(()) } else { retry_builder_api!(async { @@ -183,7 +183,7 @@ async fn download_key(ui: &mut UI, ui.progress()) .await?; ui.status(Status::Cached, - &format!("{} to {}", named_revision, key_cache.as_ref().display()))?; + format!("{} to {}", named_revision, key_cache.as_ref().display()))?; Ok::<_, habitat_api_client::error::Error>(()) }).await .map_err(|e| { diff --git a/components/hab/src/command/pkg/download.rs b/components/hab/src/command/pkg/download.rs index 7704a8110b..079e3335a3 100644 --- a/components/hab/src/command/pkg/download.rs +++ b/components/hab/src/command/pkg/download.rs @@ -142,7 +142,6 @@ pub struct PackageSet { /// dependencies will be downloaded on the system in the /// /artifacts directory. Any signing keys will also be /// downloaded and put in the directory. - /// Also, in the future we may want to accept an alternate builder to 'filter' what we pull down by /// That would greatly optimize the 'sync' to on prem builder case, as we could point to that /// and only fetch what we don't already have. @@ -217,7 +216,7 @@ struct DownloadTask<'a> { ignore_missing_seeds: bool, } -impl<'a> DownloadTask<'a> { +impl DownloadTask<'_> { async fn execute(&self, ui: &mut T) -> Result where T: UIWriter { diff --git a/components/hab/src/command/pkg/export/export_common.rs b/components/hab/src/command/pkg/export/export_common.rs index 0e0309e7db..5fe577e057 100644 --- a/components/hab/src/command/pkg/export/export_common.rs +++ b/components/hab/src/command/pkg/export/export_common.rs @@ -21,7 +21,7 @@ use std::{ffi::OsString, /// 1. `export_cmd_envvar` is checked for the raw command. /// 2. `export_pkg_ident_envvar` is checked for an explicit habitat package. /// 3. The habitat package is implicitly determined using the `export_cmd` name and the current -/// version. The package is assumed to be found in core. (eg /core//) +/// version. The package is assumed to be found in core. (eg /core//) pub async fn start(ui: &mut UI, args: &[OsString], export_cmd_envvar: &str, diff --git a/components/hab/src/command/plan/init.rs b/components/hab/src/command/plan/init.rs index a14d4b2b04..6d5cd96dc6 100644 --- a/components/hab/src/command/plan/init.rs +++ b/components/hab/src/command/plan/init.rs @@ -176,7 +176,7 @@ fn render_ignorefile(ui: &mut UI, root: &str) -> Result<()> { } fn is_git_managed(path: &Path) -> bool { - path.join(".git").is_dir() || path.parent().map_or(false, is_git_managed) + path.join(".git").is_dir() || path.parent().is_some_and(is_git_managed) } fn create_with_template(ui: &mut UI, location: &str, template: &str) -> Result<()> { diff --git a/components/hab/src/command/studio/enter.rs b/components/hab/src/command/studio/enter.rs index 0e1e189b48..83c8ccc6a6 100644 --- a/components/hab/src/command/studio/enter.rs +++ b/components/hab/src/command/studio/enter.rs @@ -238,7 +238,7 @@ mod inner { fn has_docker_group() -> Result { let current_user = users::get_current_username()?.unwrap(); let docker_members = users::get_members_by_groupname("docker")?; - Ok(docker_members.map_or(false, |d| d.contains(¤t_user))) + Ok(docker_members.is_some_and(|d| d.contains(¤t_user))) } fn rerun_with_sudo_if_needed(ui: &mut UI, diff --git a/components/hab/src/scaffolding.rs b/components/hab/src/scaffolding.rs index 22aa015243..783d3fbd6a 100644 --- a/components/hab/src/scaffolding.rs +++ b/components/hab/src/scaffolding.rs @@ -25,31 +25,31 @@ pub fn scaffold_check(ui: &mut UI, maybe_scaffold: Option<&str>) -> Result { let ident = PackageIdent::from_str(SCAFFOLDING_GO_IDENT)?; - ui.status(Status::Using, &format!("Go Scaffolding '{}'", ident))?; + ui.status(Status::Using, format!("Go Scaffolding '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } SCAFFOLDING_GRADLE_IDENT | "gradle" => { let ident = PackageIdent::from_str(SCAFFOLDING_GRADLE_IDENT)?; - ui.status(Status::Using, &format!("Gradle Scaffolding '{}'", ident))?; + ui.status(Status::Using, format!("Gradle Scaffolding '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } SCAFFOLDING_NODE_IDENT | "node" => { let ident = PackageIdent::from_str(SCAFFOLDING_NODE_IDENT)?; - ui.status(Status::Using, &format!("Node Scaffolding '{}'", ident))?; + ui.status(Status::Using, format!("Node Scaffolding '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } SCAFFOLDING_RUBY_IDENT | "ruby" => { let ident = PackageIdent::from_str(SCAFFOLDING_RUBY_IDENT)?; - ui.status(Status::Using, &format!("Ruby Scaffolding '{}'", ident))?; + ui.status(Status::Using, format!("Ruby Scaffolding '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } _ => { let ident = PackageIdent::from_str(scaffold)?; - ui.status(Status::Using, &format!("custom Scaffolding: '{}'", ident))?; + ui.status(Status::Using, format!("custom Scaffolding: '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } @@ -71,25 +71,25 @@ fn autodiscover_scaffolding(ui: &mut UI) -> Result> { if is_project_go(current_path) { let ident = PackageIdent::from_str(SCAFFOLDING_GO_IDENT).unwrap(); ui.begin("We've detected a Go codebase")?; - ui.status(Status::Using, &format!("Scaffolding package: '{}'", ident))?; + ui.status(Status::Using, format!("Scaffolding package: '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } else if is_project_gradle(current_path) { let ident = PackageIdent::from_str(SCAFFOLDING_GRADLE_IDENT).unwrap(); ui.begin("We've detected a Gradle codebase")?; - ui.status(Status::Using, &format!("Scaffolding package: '{}'", ident))?; + ui.status(Status::Using, format!("Scaffolding package: '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } else if is_project_node(current_path) { let ident = PackageIdent::from_str(SCAFFOLDING_NODE_IDENT).unwrap(); ui.begin("We've detected a Node.js codebase")?; - ui.status(Status::Using, &format!("Scaffolding package: '{}'", ident))?; + ui.status(Status::Using, format!("Scaffolding package: '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } else if is_project_ruby(current_path) { let ident = PackageIdent::from_str(SCAFFOLDING_RUBY_IDENT).unwrap(); ui.begin("We've detected a Ruby codebase")?; - ui.status(Status::Using, &format!("Scaffolding package: '{}'", ident))?; + ui.status(Status::Using, format!("Scaffolding package: '{}'", ident))?; ui.para("")?; Ok(Some(ident)) } else { diff --git a/components/launcher-protocol/build.rs b/components/launcher-protocol/build.rs index e21291633b..19cdf256a2 100644 --- a/components/launcher-protocol/build.rs +++ b/components/launcher-protocol/build.rs @@ -3,7 +3,6 @@ /// /// Generated code is deposited in `OUT_DIR` and automatically /// `include!`-ed in our Rust modules, per standard Prost practice. - fn main() { let mut config = prost_build::Config::new(); config.type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]"); diff --git a/components/launcher/src/server.rs b/components/launcher/src/server.rs index 5449c483b7..17b222ddc7 100644 --- a/components/launcher/src/server.rs +++ b/components/launcher/src/server.rs @@ -596,7 +596,7 @@ fn is_supported_supervisor_version(version_output: &str) -> bool { .split_whitespace() // ["hab-sup", ] .last() // drop "hab-sup", keep .unwrap() // split() always returns an 1+ element iterator - .split(|c| c == '/' || c == '-') // strip "-dev" or "/build" + .split(['/', '-']) // strip "-dev" or "/build" .next() { debug!("Checking Supervisor version '{}' against requirement '{}'", diff --git a/components/pkg-export-container/src/build.rs b/components/pkg-export-container/src/build.rs index 683495a42e..b3363630cf 100644 --- a/components/pkg-export-container/src/build.rs +++ b/components/pkg-export-container/src/build.rs @@ -137,6 +137,7 @@ impl TryFrom<&ArgMatches> for BuildSpec { } Err(_) => default_base_image().expect("No base image supported"), }; + let stable = &String::from("stable"); // TODO (CM): incorporate this into our CLAP definition better Ok(BuildSpec { hab: m.get_one::("HAB_PKG").unwrap().to_string(), @@ -146,14 +147,14 @@ impl TryFrom<&ArgMatches> for BuildSpec { hab_sup: m.get_one::("HAB_SUP_PKG").unwrap().to_string(), url: m.get_one::("BLDR_URL").unwrap().to_string(), channel: m.get_one::("CHANNEL") - .unwrap_or(&"stable".to_string()) + .unwrap_or(stable) .to_string() .into(), base_pkgs_url: m.get_one::("BASE_PKGS_BLDR_URL") .unwrap() .to_string(), base_pkgs_channel: m.get_one::("BASE_PKGS_CHANNEL") - .unwrap_or(&"stable".to_string()) + .unwrap_or(stable) .to_string() .into(), auth: m.get_one::("BLDR_AUTH_TOKEN") @@ -776,7 +777,7 @@ impl BuildRootContext { fn validate(&self) -> Result<()> { // A valid context for a build root will contain at least one service package, called the // primary service package. - if self.svc_idents().first().is_none() { + if self.svc_idents().is_empty() { return Err(Error::PrimaryServicePackageNotFound(self.idents .iter() .map(|e| e.ident().to_string()) diff --git a/components/sup-protocol/build.rs b/components/sup-protocol/build.rs index ba0e549813..33e79370e6 100644 --- a/components/sup-protocol/build.rs +++ b/components/sup-protocol/build.rs @@ -3,7 +3,6 @@ /// /// Generated code is deposited in `OUT_DIR` and automatically /// `include!`-ed in our Rust modules, per standard Prost practice. - fn main() { let mut config = prost_build::Config::new(); config.type_attribute(".", diff --git a/components/sup/src/census.rs b/components/sup/src/census.rs index b87577316d..f64bed8de2 100644 --- a/components/sup/src/census.rs +++ b/components/sup/src/census.rs @@ -229,7 +229,7 @@ impl<'a> CensusRingProxy<'a> { pub fn new(c: &'a CensusRing) -> Self { CensusRingProxy(c) } } -impl<'a> Serialize for CensusRingProxy<'a> { +impl Serialize for CensusRingProxy<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { @@ -697,7 +697,7 @@ impl std::ops::Deref for CensusMemberProxy<'_> { fn deref(&self) -> &Self::Target { &(self.0) } } -impl<'a> Serialize for CensusMemberProxy<'a> { +impl Serialize for CensusMemberProxy<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { diff --git a/components/sup/src/lib.rs b/components/sup/src/lib.rs index 51abb42e1d..7340de5d92 100644 --- a/components/sup/src/lib.rs +++ b/components/sup/src/lib.rs @@ -4,10 +4,10 @@ //! Habitat contains two main components: //! //! * `hab-plan-build`, takes a plan ('plan.sh'), a description of how to build a piece of software, -//! written in [bash](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html), which produces an atomic -//! package. -//! * `hab-sup`, a run-time executable that knows how to download, install, serve, and -//! manage services defined in packages. +//! written in [bash](http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html), which produces an atomic +//! package. +//! * `hab-sup`, a run-time executable that knows how to download, install, serve, and manage +//! services defined in packages. //! //! # hab-plan-build //! diff --git a/components/sup/src/lock_file.rs b/components/sup/src/lock_file.rs index 00c66e950b..6745476811 100644 --- a/components/sup/src/lock_file.rs +++ b/components/sup/src/lock_file.rs @@ -223,16 +223,16 @@ impl LockFile { // See // [LockFileEx](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-lockfileex) // for more. - file.try_lock_shared().map_err(|e| { - if cfg!(windows) { - Error::CannotAcquireSharedLock(e) - } else { - // Unix, Linux, et al. - Error::LockDowngrade(e) - } - })?; + fs2::FileExt::try_lock_shared(&file).map_err(|e| { + if cfg!(windows) { + Error::CannotAcquireSharedLock(e) + } else { + // Unix, Linux, et al. + Error::LockDowngrade(e) + } + })?; if cfg!(windows) { - file.unlock().map_err(Error::CannotReleaseExclusiveLock)?; + fs2::FileExt::unlock(&file).map_err(Error::CannotReleaseExclusiveLock)?; } // Now, anyone should be able to read the file, but another Supervisor @@ -267,7 +267,7 @@ impl Drop for LockFile { /// https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-unlockfile#remarks /// [2]: http://www.guido-flohr.net/never-delete-your-pid-file/ fn drop(&mut self) { - if let Err(e) = self.file.unlock() { + if let Err(e) = fs2::FileExt::unlock(&self.file) { error!("Error unlocking '{}'; proceeding anyway: {:?}", lock_file_path().display(), e); @@ -456,7 +456,7 @@ mod tests { let file = write_to_file(&lock_path, "LOLWUT"); // Lock the file so we can get past that check. - file.lock_shared().unwrap(); + fs2::FileExt::lock_shared(&file).unwrap(); // Trying to get the PID out will fail now. read_lock_file_impl(lock_path).unwrap(); diff --git a/components/sup/src/manager.rs b/components/sup/src/manager.rs index e6039d6344..4ffcbe6a2a 100644 --- a/components/sup/src/manager.rs +++ b/components/sup/src/manager.rs @@ -851,10 +851,10 @@ impl Manager { for entry in entries.flatten() { match entry.path().extension().and_then(OsStr::to_str) { Some("tmp") | Some("health") => { - fs::remove_file(&entry.path()).map_err(|err| { - Error::BadDataPath(data_path.clone(), - err) - })?; + fs::remove_file(entry.path()).map_err(|err| { + Error::BadDataPath(data_path.clone(), + err) + })?; } _ => continue, } @@ -1896,7 +1896,7 @@ impl Manager { .services .lock_msr() .get(&spec.ident) - .map_or(true, PersistentServiceWrapper::is_ready_for_restart) + .is_none_or(PersistentServiceWrapper::is_ready_for_restart) { self.add_service_rsw_mlw_rhw_msr(spec.clone()).await; services_started.push(spec.ident.clone()); diff --git a/components/sup/src/manager/service.rs b/components/sup/src/manager/service.rs index 9d4ebf5209..b54bec8514 100644 --- a/components/sup/src/manager/service.rs +++ b/components/sup/src/manager/service.rs @@ -164,7 +164,7 @@ impl TemplateUpdate { /// /// A restart is needed under the following conditions: /// 1. the `init`, `run` or `post-run` hooks have changed. A restart is limited to these hooks - /// because they are the only hooks that can impact the execution of the service. + /// because they are the only hooks that can impact the execution of the service. /// 2. `/config` changed and there is no `reconfigure` hook fn needs_restart(&self) -> Option { if self.hooks.init_changed() { diff --git a/components/sup/src/manager/service/context.rs b/components/sup/src/manager/service/context.rs index d0012bd6f4..5e8598d526 100644 --- a/components/sup/src/manager/service/context.rs +++ b/components/sup/src/manager/service/context.rs @@ -198,7 +198,7 @@ impl<'a> Package<'a> { } } -impl<'a> Serialize for Package<'a> { +impl Serialize for Package<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { @@ -285,7 +285,7 @@ impl<'a> Svc<'a> { } } -impl<'a> Serialize for Svc<'a> { +impl Serialize for Svc<'_> { fn serialize(&self, serializer: S) -> result::Result where S: Serializer { diff --git a/rust-toolchain b/rust-toolchain index 628740b12f..c1bc0a6944 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,2 +1,2 @@ [toolchain] -channel = "1.79.0" +channel = "1.85.0"