From d5846bbaeefacf29b2ec176cf55bac8340795714 Mon Sep 17 00:00:00 2001 From: Jason Heath Date: Thu, 2 Mar 2023 07:07:48 -0500 Subject: [PATCH] Revved rust from 1.62.1 to 1.67.1 - Address Clippy warnings while upgrading from 1.62.1 to 1.67.1 - A fix for the change in signal masking introduced in https://github.com/rust-lang/rust/pull/101077/ - Changes to address an instance of https://rust-lang.github.io/rust-clippy/master/index.html\#result_large_err Signed-off-by: Jason Heath --- .rustfmt.toml | 2 +- components/builder-api-client/src/builder.rs | 4 +- components/butterfly/src/client.rs | 2 +- components/butterfly/src/member.rs | 2 +- components/butterfly/src/protocol/swim.rs | 8 +-- components/butterfly/src/rumor/dat_file.rs | 2 +- components/butterfly/src/rumor/heat.rs | 2 +- components/butterfly/src/server.rs | 2 +- .../butterfly/src/server/incarnation_store.rs | 6 +-- components/common/src/cli.rs | 2 +- components/common/src/cli_config.rs | 4 +- components/common/src/owning_refs.rs | 10 ++-- components/common/src/templating.rs | 12 ++--- components/common/src/templating/config.rs | 16 +++--- .../src/templating/helpers/each_alive.rs | 4 +- components/common/src/templating/hooks.rs | 32 ++++++------ components/common/src/ui.rs | 2 +- components/common/src/util/path.rs | 2 +- components/core/build.rs | 2 +- components/core/src/crypto/artifact.rs | 8 +-- components/core/src/crypto/hash.rs | 8 +-- components/core/src/env.rs | 11 +--- components/core/src/error.rs | 2 +- components/core/src/fs.rs | 35 +++++++------ components/core/src/os/ffi/windows.rs | 4 +- components/core/src/os/process/exec/unix.rs | 22 ++++++-- components/core/src/os/process/windows.rs | 2 +- .../core/src/os/process/windows_child.rs | 2 +- components/core/src/os/system/linux.rs | 2 +- components/core/src/package/archive.rs | 2 +- components/core/src/package/install.rs | 50 +++++++++---------- components/core/src/package/list.rs | 4 +- components/core/src/package/metadata.rs | 2 +- components/core/src/tls/ctl_gateway.rs | 8 +-- .../src/tls/native_tls_wrapper/readers.rs | 2 +- components/hab/src/command/pkg/binlink.rs | 2 +- components/hab/src/command/pkg/download.rs | 2 +- components/hab/src/command/pkg/hash.rs | 2 +- components/hab/src/command/pkg/search.rs | 2 +- .../command/pkg/uninstall/uninstall_impl.rs | 10 ++-- components/hab/src/command/plan/render.rs | 6 +-- components/hab/src/command/studio/docker.rs | 2 +- components/hab/src/command/studio/enter.rs | 8 +-- components/hab/src/main.rs | 18 +++---- components/hab/src/scaffolding.rs | 10 ++-- components/http-client/src/api_client.rs | 2 +- components/launcher/src/error.rs | 5 +- .../launcher/src/sys/windows/service.rs | 4 +- components/pkg-export-container/src/build.rs | 2 +- components/pkg-export-container/src/cli.rs | 2 +- .../pkg-export-container/src/container.rs | 4 +- .../src/engine/buildah.rs | 16 +++--- .../pkg-export-container/src/engine/docker.rs | 14 +++--- components/pkg-export-container/src/lib.rs | 6 +-- components/pkg-export-tar/src/build.rs | 12 ++--- components/pkg-export-tar/src/main.rs | 2 +- components/sup/src/ctl_gateway/server.rs | 3 +- components/sup/src/http_gateway.rs | 6 +-- components/sup/src/manager.rs | 14 +++--- components/sup/src/manager/file_watcher.rs | 2 +- components/sup/src/manager/service.rs | 10 ++-- components/sup/src/manager/service/hooks.rs | 50 +++++++++---------- .../src/manager/service/pipe_hook_client.rs | 36 ++++++------- .../sup/src/manager/service/supervisor.rs | 2 +- .../service_updater/rolling_update_worker.rs | 2 +- components/sup/src/manager/spec_watcher.rs | 2 +- .../sup/src/manager/user_config_watcher.rs | 4 +- components/sup/src/sys/windows/service.rs | 2 +- components/sup/src/util/pkg.rs | 4 +- components/sup/tests/utils/test_sup.rs | 2 +- components/win-users/src/sid.rs | 8 +-- rust-toolchain | 2 +- support/denied_lints.txt | 2 +- 73 files changed, 282 insertions(+), 280 deletions(-) diff --git a/.rustfmt.toml b/.rustfmt.toml index 135977d1df..510bfd15b3 100644 --- a/.rustfmt.toml +++ b/.rustfmt.toml @@ -6,7 +6,7 @@ unstable_features = true # stable options edition = "2018" -fn_args_layout = "Tall" +fn_params_layout = "Tall" force_explicit_abi = true format_code_in_doc_comments = true hard_tabs = false diff --git a/components/builder-api-client/src/builder.rs b/components/builder-api-client/src/builder.rs index a920bc950b..f1f559c46f 100644 --- a/components/builder-api-client/src/builder.rs +++ b/components/builder-api-client/src/builder.rs @@ -190,7 +190,7 @@ impl BuilderAPIClient { let resp = self.maybe_add_authz(rb, token).send().await?; let resp = response::ok_if(resp, &[StatusCode::OK]).await?; - fs::create_dir_all(&dst_path)?; + fs::create_dir_all(dst_path)?; let file_name = response::get_header(&resp, X_FILENAME)?; let dst_file_path = dst_path.join(file_name); let w = AtomicWriter::new_with_permissions(&dst_file_path, permissions)?; @@ -1609,7 +1609,7 @@ mod tests { (range, (range + step).min(last)) }; let filtered_range = filtered[start..=end].iter() - .map(|s| get_test_ident(**s)) + .map(|s| get_test_ident(s)) .collect::>(); let result = PackageResults { range_start: start as isize, range_end: end as isize, diff --git a/components/butterfly/src/client.rs b/components/butterfly/src/client.rs index 36095febf9..7ff8f23b0d 100644 --- a/components/butterfly/src/client.rs +++ b/components/butterfly/src/client.rs @@ -81,6 +81,6 @@ impl Client { { let bytes = rumor.write_to_bytes()?; let wire_msg = message::generate_wire(bytes, self.ring_key.as_ref())?; - self.socket.send(&wire_msg, 0).map_err(Error::ZmqSendError) + self.socket.send(wire_msg, 0).map_err(Error::ZmqSendError) } } diff --git a/components/butterfly/src/member.rs b/components/butterfly/src/member.rs index 3f6d58095b..ec2a6044b8 100644 --- a/components/butterfly/src/member.rs +++ b/components/butterfly/src/member.rs @@ -174,7 +174,7 @@ impl Default for Member { } impl From for RumorKey { - fn from(member: Member) -> RumorKey { RumorKey::new(RumorType::Member, &member.id, "") } + fn from(member: Member) -> RumorKey { RumorKey::new(RumorType::Member, member.id, "") } } impl<'a> From<&'a Member> for RumorKey { diff --git a/components/butterfly/src/protocol/swim.rs b/components/butterfly/src/protocol/swim.rs index d4cd923711..6cd69c138a 100644 --- a/components/butterfly/src/protocol/swim.rs +++ b/components/butterfly/src/protocol/swim.rs @@ -24,10 +24,10 @@ mod tests { #[test] fn health_values_are_title_case() { - assert_eq!(serde_json::to_value(&Health::Alive).unwrap(), "Alive"); - assert_eq!(serde_json::to_value(&Health::Suspect).unwrap(), "Suspect"); - assert_eq!(serde_json::to_value(&Health::Confirmed).unwrap(), + assert_eq!(serde_json::to_value(Health::Alive).unwrap(), "Alive"); + assert_eq!(serde_json::to_value(Health::Suspect).unwrap(), "Suspect"); + assert_eq!(serde_json::to_value(Health::Confirmed).unwrap(), "Confirmed"); - assert_eq!(serde_json::to_value(&Health::Departed).unwrap(), "Departed"); + assert_eq!(serde_json::to_value(Health::Departed).unwrap(), "Departed"); } } diff --git a/components/butterfly/src/rumor/dat_file.rs b/components/butterfly/src/rumor/dat_file.rs index 47a8781191..fccc5e368f 100644 --- a/components/butterfly/src/rumor/dat_file.rs +++ b/components/butterfly/src/rumor/dat_file.rs @@ -368,7 +368,7 @@ impl DatFile { { let mut bytes_read = 0; let mut size_buf = [0; 8]; - let mut rumor_buf: Vec = vec![]; + let mut rumor_buf: Vec = vec![0; 8]; loop { if bytes_read >= offset { diff --git a/components/butterfly/src/rumor/heat.rs b/components/butterfly/src/rumor/heat.rs index bfebdb6ffe..c6e0a5870d 100644 --- a/components/butterfly/src/rumor/heat.rs +++ b/components/butterfly/src/rumor/heat.rs @@ -75,7 +75,7 @@ pub(crate) mod sync { .collect(); // Reverse sorting by heat; 0s come last! - rumor_heat.sort_by(|&(_, ref h1), &(_, ref h2)| h2.cmp(h1)); + rumor_heat.sort_by(|(_, h1), (_, h2)| h2.cmp(h1)); // We don't need the heat anymore, just return the rumors. rumor_heat.into_iter().map(|(k, _)| k).collect() diff --git a/components/butterfly/src/server.rs b/components/butterfly/src/server.rs index 0916b8bd8a..c839514eb0 100644 --- a/components/butterfly/src/server.rs +++ b/components/butterfly/src/server.rs @@ -748,7 +748,7 @@ impl Server { rumor_heat.lock_rhw().purge(member_id_to_depart); rumor_heat.lock_rhw() .start_hot_rumor(RumorKey::new(RumorType::Member, - &*member_id_to_depart, + member_id_to_depart, "")); } } diff --git a/components/butterfly/src/server/incarnation_store.rs b/components/butterfly/src/server/incarnation_store.rs index 18d09197ef..ddd0b816ce 100644 --- a/components/butterfly/src/server/incarnation_store.rs +++ b/components/butterfly/src/server/incarnation_store.rs @@ -97,7 +97,7 @@ mod tests { "The path {:?} shouldn't exist, but it does", path); - let i = IncarnationStore::new(&path); + let i = IncarnationStore::new(path); assert!(i.load().is_err()); } @@ -155,13 +155,13 @@ mod tests { let tempfile = Temp::new_file().expect("Could not create temp file"); let path = tempfile.as_ref(); - let mut buffer = File::create(&path).expect("could not create file"); + let mut buffer = File::create(path).expect("could not create file"); buffer.write_all(b"this, also, is not a u64") .expect("could not write file"); assert!(path.exists()); - let mut i = IncarnationStore::new(&path); + let mut i = IncarnationStore::new(path); assert!(i.initialize().is_err()); } } diff --git a/components/common/src/cli.rs b/components/common/src/cli.rs index 45e046f94d..623124b1b9 100644 --- a/components/common/src/cli.rs +++ b/components/common/src/cli.rs @@ -61,7 +61,7 @@ pub fn is_toml_file(val: &str) -> bool { } pub fn file_into_idents(path: &str) -> Result, habitat_core::error::Error> { - let s = std::fs::read_to_string(&path).map_err(|_| { + let s = std::fs::read_to_string(path).map_err(|_| { habitat_core::error::Error::FileNotFound(format!("Could not open file {}", path)) })?; diff --git a/components/common/src/cli_config.rs b/components/common/src/cli_config.rs index e1935ff1f7..ac35011eaa 100644 --- a/components/common/src/cli_config.rs +++ b/components/common/src/cli_config.rs @@ -64,7 +64,7 @@ impl CliConfig { } /// Get a reference to the `CliConfig` cached at startup - pub fn cache() -> &'static Self { &*CACHED_CLI_CONFIG } + pub fn cache() -> &'static Self { &CACHED_CLI_CONFIG } /// Load an up to date `CliConfig` from disk pub fn load() -> Result { @@ -79,7 +79,7 @@ impl CliConfig { /// Save the `CliConfig` to disk pub fn save(&self) -> Result<(), Error> { - fs::create_dir_all(&*CLI_CONFIG_PATH_PARENT)?; + fs::create_dir_all(*CLI_CONFIG_PATH_PARENT)?; let raw = toml::ser::to_string(self)?; debug!("Raw config toml:\n---\n{}\n---", &raw); fs::write(&*CLI_CONFIG_PATH, raw)?; diff --git a/components/common/src/owning_refs.rs b/components/common/src/owning_refs.rs index a91f806f78..3bbf0932a4 100644 --- a/components/common/src/owning_refs.rs +++ b/components/common/src/owning_refs.rs @@ -15,11 +15,11 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableMutexGuard<'a, T> {} impl Deref for StableMutexGuard<'_, T> { type Target = T; - fn deref(&self) -> &T { &*self.0 } + fn deref(&self) -> &T { &self.0 } } impl DerefMut for StableMutexGuard<'_, T> { - fn deref_mut(&mut self) -> &mut T { &mut *self.0 } + fn deref_mut(&mut self) -> &mut T { &mut self.0 } } impl<'a, T> From> for StableMutexGuard<'a, T> { @@ -35,7 +35,7 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockReadGuard<'a, T> {} impl Deref for StableRwLockReadGuard<'_, T> { type Target = T; - fn deref(&self) -> &T { &*self.0 } + fn deref(&self) -> &T { &self.0 } } impl<'a, T> From> for StableRwLockReadGuard<'a, T> { @@ -51,11 +51,11 @@ unsafe impl<'a, T: ?Sized> StableAddress for StableRwLockWriteGuard<'a, T> {} impl Deref for StableRwLockWriteGuard<'_, T> { type Target = T; - fn deref(&self) -> &T { &*self.0 } + fn deref(&self) -> &T { &self.0 } } impl DerefMut for StableRwLockWriteGuard<'_, T> { - fn deref_mut(&mut self) -> &mut T { &mut *self.0 } + fn deref_mut(&mut self) -> &mut T { &mut self.0 } } impl<'a, T> From> for StableRwLockWriteGuard<'a, T> { diff --git a/components/common/src/templating.rs b/components/common/src/templating.rs index 045f2ce087..fe436f0938 100644 --- a/components/common/src/templating.rs +++ b/components/common/src/templating.rs @@ -50,15 +50,15 @@ pub async fn compile_for_package_install(package: &PackageInstall, cfg_renderer.compile(&pkg.name, &pkg, &pkg.svc_config_install_path, &ctx)?; if let Some(ref hook) = InstallHook::load(&pkg.name, - &fs::svc_hooks_path(&pkg.name), - &package.installed_path.join("hooks"), + fs::svc_hooks_path(&pkg.name), + package.installed_path.join("hooks"), feature_flags) { hook.compile(&pkg.name, &ctx)?; }; if let Some(ref hook) = UninstallHook::load(&pkg.name, - &fs::svc_hooks_path(&pkg.name), - &package.installed_path.join("hooks"), + fs::svc_hooks_path(&pkg.name), + package.installed_path.join("hooks"), feature_flags) { hook.compile(&pkg.name, &ctx)?; @@ -218,8 +218,8 @@ mod test { pub fn toml_to_json(value: toml::Value) -> serde_json::Value { match value { toml::Value::String(s) => serde_json::Value::String(s), - toml::Value::Integer(i) => serde_json::Value::from(i as i64), - toml::Value::Float(i) => serde_json::Value::from(i as f64), + toml::Value::Integer(i) => serde_json::Value::from(i), + toml::Value::Float(i) => serde_json::Value::from(i), toml::Value::Boolean(b) => serde_json::Value::Bool(b), toml::Value::Datetime(s) => serde_json::Value::String(s.to_string()), toml::Value::Array(a) => toml_vec_to_json(a), diff --git a/components/common/src/templating/config.rs b/components/common/src/templating/config.rs index fdd1d12397..582c690abc 100644 --- a/components/common/src/templating/config.rs +++ b/components/common/src/templating/config.rs @@ -198,7 +198,7 @@ impl Cfg { /// exports. pub fn to_exported(&self, pkg: &Pkg) -> Result { let mut map = toml::value::Table::default(); - let cfg = toml::Value::try_from(&self).expect("Cfg -> TOML conversion"); + let cfg = toml::Value::try_from(self).expect("Cfg -> TOML conversion"); for (key, path) in pkg.exports.iter() { let mut curr = &cfg; let mut found = false; @@ -229,7 +229,7 @@ impl Cfg { T2: AsRef { let filename = file.as_ref(); - let path = dir.as_ref().join(&filename); + let path = dir.as_ref().join(filename); let mut file = match File::open(&path) { Ok(file) => file, Err(e) => { @@ -429,7 +429,7 @@ impl CfgRenderer { for template in self.0.get_templates().keys() { let compiled = self.0.render(template, ctx)?; let compiled_hash = Blake2bHash::from_bytes(&compiled); - let cfg_dest = render_path.as_ref().join(&template); + let cfg_dest = render_path.as_ref().join(template); let file_hash = match Blake2bHash::from_file(&cfg_dest) { Ok(file_hash) => Some(file_hash), Err(e) => { @@ -536,7 +536,7 @@ fn set_permissions(path: &Path, user: &str, group: &str) -> hcore::error::Result } else { CONFIG_PERMISSIONS }; - posix_perm::set_permissions(&path, permissions) + posix_perm::set_permissions(path, permissions) } #[cfg(windows)] @@ -585,12 +585,12 @@ fn ensure_directory_structure(root: &Path, file: &Path, user: &str, group: &str) // that `root` exists, so that we don't create arbitrary directory // structures on disk assert!(root.is_dir()); - assert!(file.starts_with(&root)); + assert!(file.starts_with(root)); let dir = file.parent().unwrap(); if !dir.exists() { - std::fs::create_dir_all(&dir)?; + std::fs::create_dir_all(dir)?; for anc in dir.ancestors().take_while(|&d| d != root) { set_permissions(anc, user, group)?; } @@ -967,7 +967,7 @@ mod test { package_name: &str, input_config: &str, expected_config_as_toml: &str) { - env::set_var(env_key, &input_config); + env::set_var(env_key, input_config); let expected = toml_from_str(expected_config_as_toml); let result = Cfg::load_environment(package_name); @@ -1006,7 +1006,7 @@ mod test { let key = "HAB_TESTING_TRASH"; let config = "{\"port: 1234 what even is this!!!!?! ="; - env::set_var(key, &config); + env::set_var(key, config); let result = Cfg::load_environment("testing-trash"); diff --git a/components/common/src/templating/helpers/each_alive.rs b/components/common/src/templating/helpers/each_alive.rs index 2ff1481f8a..4d574d4ddb 100644 --- a/components/common/src/templating/helpers/each_alive.rs +++ b/components/common/src/templating/helpers/each_alive.rs @@ -22,7 +22,7 @@ impl HelperDef for EachAliveHelper { let local_path_root = value.path_root() .map(|p| format!("{}/{}", rc.get_path(), p)); let rendered = match (value.value().is_truthy(), value.value()) { - (true, &Json::Array(ref list)) => { + (true, Json::Array(list)) => { let alive_members: Vec = list.iter() .filter_map(|m| { m.as_object().and_then(|m| { @@ -55,7 +55,7 @@ impl HelperDef for EachAliveHelper { } Ok(()) } - (true, &Json::Object(ref obj)) => { + (true, Json::Object(obj)) => { let mut first: bool = true; if !obj.contains_key("alive") || !obj["alive"].as_bool().unwrap() { return Ok(()); diff --git a/components/common/src/templating/hooks.rs b/components/common/src/templating/hooks.rs index 1502bf033c..89514d7701 100644 --- a/components/common/src/templating/hooks.rs +++ b/components/common/src/templating/hooks.rs @@ -84,8 +84,8 @@ pub trait Hook: fmt::Debug + Sized + Send { } else { None }; - let concrete = concrete_path.as_ref().join(&file_name); - let template = template_path.as_ref().join(&file_name); + let concrete = concrete_path.as_ref().join(file_name); + let template = template_path.as_ref().join(file_name); let deprecated_template = deprecated_file_name.as_ref() .map(|n| template_path.as_ref().join(n)); @@ -120,7 +120,7 @@ pub trait Hook: fmt::Debug + Sized + Send { template.display()); return None; }; - match RenderPair::new(concrete, &template_to_use, Self::FILE_NAME) { + match RenderPair::new(concrete, template_to_use, Self::FILE_NAME) { Ok(pair) => Some(Self::new(package_name, pair, feature_flags)), Err(err) => { outputln!(preamble package_name, "Failed to load hook: {}", err); @@ -274,11 +274,7 @@ pub trait Hook: fmt::Debug + Sized + Send { Ok(cmd.spawn()?) } - fn handle_exit<'a>(&self, - pkg: &Pkg, - output: &'a HookOutput, - status: ExitStatus) - -> Self::ExitValue; + fn handle_exit(&self, pkg: &Pkg, output: &HookOutput, status: ExitStatus) -> Self::ExitValue; /// Return true if this hook should be retried provided the exit value of the previous run. fn should_retry(_exit_value: &Self::ExitValue) -> bool { false } @@ -377,7 +373,7 @@ impl Hook for InstallHook { stderr_log_path: stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { let name = &pkg.name; if let Some(code) = status.code() { let path = pkg.path.join(InstallHook::STATUS_FILE); @@ -447,7 +443,7 @@ impl Hook for UninstallHook { stderr_log_path: stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { let name = &pkg.name; match status.code() { Some(code) if !status.success() => { @@ -494,7 +490,7 @@ fn hash_content(path: T) -> Result> fn write_hook(content: &str, path: T) -> Result where T: AsRef { - let content_hash = Blake2bHash::from_bytes(&content); + let content_hash = Blake2bHash::from_bytes(content); let existing_hash = hash_content(path.as_ref())?; if let Some(existing_hash) = existing_hash { if existing_hash == content_hash { @@ -555,7 +551,7 @@ impl<'a> HookOutput<'a> { } pub fn stdout(&self) -> Result> { - Ok(BufReader::new(File::open(&self.stdout_log_file)?)) + Ok(BufReader::new(File::open(self.stdout_log_file)?)) } pub fn stdout_str(&self) -> Result { @@ -567,7 +563,7 @@ impl<'a> HookOutput<'a> { } pub fn stderr(&self) -> Result> { - Ok(BufReader::new(File::open(&self.stderr_log_file)?)) + Ok(BufReader::new(File::open(self.stderr_log_file)?)) } pub fn stderr_str(&self) -> Result { @@ -691,7 +687,7 @@ mod tests { let hook = InstallHook::load(&service_group, &concrete_path, - &template_path, + template_path, FeatureFlag::empty()).expect("Could not create testing \ install hook"); @@ -713,7 +709,7 @@ echo "The message is Hello World" let template_path = hook_templates_path(); let hook = InstallHook::load(&service_group, &concrete_path, - &template_path, + template_path, FeatureFlag::empty()).expect("Could not create testing \ install hook"); @@ -728,7 +724,7 @@ echo "The message is Hello World" let hook = InstallHook::load(&service_group, &concrete_path, - &template_path, + template_path, FeatureFlag::empty()).expect("Could not create testing \ install hook"); @@ -761,7 +757,7 @@ echo "The message is Hello World" let hook = InstallHook::load(&service_group, &concrete_path, - &template_path, + template_path, FeatureFlag::empty()).expect("Could not create testing \ install hook"); @@ -791,7 +787,7 @@ echo "The message is Hello World" let hook = InstallHook::load(&service_group, &concrete_path, - &template_path, + template_path, FeatureFlag::empty()).expect("Could not create testing \ install hook"); diff --git a/components/common/src/ui.rs b/components/common/src/ui.rs index 83b13a20b3..5ca93c54c4 100644 --- a/components/common/src/ui.rs +++ b/components/common/src/ui.rs @@ -519,7 +519,7 @@ impl UIWriter for UI { fn progress(&self) -> Option> { if self.is_out_a_terminal() { - Some(Box::new(Self::ProgressBar::default())) + Some(Box::::default()) } else { None } diff --git a/components/common/src/util/path.rs b/components/common/src/util/path.rs index fa503fcd05..8f0107ff3a 100644 --- a/components/common/src/util/path.rs +++ b/components/common/src/util/path.rs @@ -101,7 +101,7 @@ async fn interpreter_paths() -> Result> { &(ident.clone(), PackageTarget::active_target()) .into(), - &*PROGRAM_NAME, + &PROGRAM_NAME, VERSION, FS_ROOT_PATH.as_path(), &cache_artifact_path(None::), diff --git a/components/core/build.rs b/components/core/build.rs index d6a7e11fdf..512685782d 100644 --- a/components/core/build.rs +++ b/components/core/build.rs @@ -14,7 +14,7 @@ fn main() { let mut file = File::create(Path::new(&env::var("OUT_DIR").unwrap()).join("hab-crypt")).unwrap(); if let Ok(key) = env::var("HAB_CRYPTO_KEY") { - file.write_all(&STANDARD.decode(&key).unwrap()).unwrap(); + file.write_all(&STANDARD.decode(key).unwrap()).unwrap(); } populate_cacert(); diff --git a/components/core/src/crypto/artifact.rs b/components/core/src/crypto/artifact.rs index d813ebb8e5..15700392d8 100644 --- a/components/core/src/crypto/artifact.rs +++ b/components/core/src/crypto/artifact.rs @@ -48,7 +48,7 @@ pub fn sign(src: &P1, dst: &P2, key: &SecretOriginSigningKey) -> Result< HART_FORMAT_VERSION, key.named_revision(), SIG_HASH_TYPE, - crate::base64::encode(&signature))?; + crate::base64::encode(signature))?; let mut file = File::open(src)?; io::copy(&mut file, &mut writer)?; Ok(()) @@ -389,7 +389,7 @@ mod test { #[test] fn get_artifact_header_works() { let hart_path = fixture("happyhumans-possums-8.1.4-20160427165340-x86_64-linux.hart"); - let header = get_artifact_header(&hart_path).unwrap(); + let header = get_artifact_header(hart_path).unwrap(); assert_eq!(header.format(), "HART-1"); assert_eq!(header.signer().to_string(), "happyhumans-20160424223347"); @@ -405,7 +405,7 @@ mod test { #[test] fn get_named_revision_from_artifact() { let hart_path = fixture("happyhumans-possums-8.1.4-20160427165340-x86_64-linux.hart"); - let signer = artifact_signer(&hart_path).unwrap(); + let signer = artifact_signer(hart_path).unwrap(); let expected: NamedRevision = "happyhumans-20160424223347".parse().unwrap(); assert_eq!(signer, expected); } @@ -417,7 +417,7 @@ mod test { // be parsed by `artifact_signer`. It has an invalid // signing key identifier. let hart_path = fixture("bogus_and_corrupt.hart"); - artifact_signer(&hart_path).unwrap(); + artifact_signer(hart_path).unwrap(); } } } diff --git a/components/core/src/crypto/hash.rs b/components/core/src/crypto/hash.rs index baf56c689d..05049b91e6 100644 --- a/components/core/src/crypto/hash.rs +++ b/components/core/src/crypto/hash.rs @@ -178,7 +178,7 @@ mod tests { let message = [0u8, 1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u8, 9u8]; let expected = hash_from_hex("8b57a796a5d07cb04cc1614dfc2acb3f73edc712d7f433619ca3bbe66bb15f49"); - let actual = Blake2bHash::from_bytes(&message); + let actual = Blake2bHash::from_bytes(message); assert_eq!(expected, actual); } @@ -189,18 +189,18 @@ mod tests { // https://github.com/dchest/b2sum using the the `-s=32` option. For example: // b2sum -s=32 signme.dat - let computed = Blake2bHash::from_file(&fixture("signme.dat")).unwrap(); + let computed = Blake2bHash::from_file(fixture("signme.dat")).unwrap(); let expected = hash_from_hex("20590a52c4f00588c500328b16d466c982a26fabaa5fa4dcc83052dd0a84f233"); assert_eq!(computed, expected); let computed = - Blake2bHash::from_file(&fixture("happyhumans-20160424223347.sig.key")).unwrap(); + Blake2bHash::from_file(fixture("happyhumans-20160424223347.sig.key")).unwrap(); let expected = hash_from_hex("e966844bbc50b7a3a6d81e94dd38e27b92814b944095a8e55f1780921bfcfbe1"); assert_eq!(computed, expected); - let computed = Blake2bHash::from_file(&fixture("happyhumans-20160424223347.pub")).unwrap(); + let computed = Blake2bHash::from_file(fixture("happyhumans-20160424223347.pub")).unwrap(); let expected = hash_from_hex("b80c4f412f9a0a7727b6e6f115e1b5fa3bae79ad2fcf47f769ed4e42cfb12265"); assert_eq!(computed, expected); diff --git a/components/core/src/env.rs b/components/core/src/env.rs index 68731253de..7d0514cb28 100644 --- a/components/core/src/env.rs +++ b/components/core/src/env.rs @@ -61,16 +61,7 @@ pub fn var>(key: K) -> std::result::Result { /// } /// ``` pub fn var_os>(key: K) -> std::option::Option { - match std::env::var_os(key) { - Some(val) => { - if val.to_string_lossy().as_ref().is_empty() { - None - } else { - Some(val) - } - } - None => None, - } + std::env::var_os(key).filter(|val| !val.to_string_lossy().as_ref().is_empty()) } /// Declare a struct that implements the `Config` trait with a minimum of boilerplate. diff --git a/components/core/src/error.rs b/components/core/src/error.rs index 38000f0e0c..df3d2be99b 100644 --- a/components/core/src/error.rs +++ b/components/core/src/error.rs @@ -123,7 +123,7 @@ pub enum Error { /// Occurs when a call to OpenDesktopW fails OpenDesktopFailed(String), /// Occurs when a suitable installed package cannot be found. - PackageNotFound(package::PackageIdent), + PackageNotFound(Box), /// Occurs where trying to unpack a package PackageUnpackFailed(String), /// When an error occurs parsing an integer. diff --git a/components/core/src/fs.rs b/components/core/src/fs.rs index 79c763f5f3..358bf2b137 100644 --- a/components/core/src/fs.rs +++ b/components/core/src/fs.rs @@ -299,7 +299,7 @@ pub fn cache_ssl_path(fs_root_path: Option) -> PathBuf pub fn pkg_root_path(fs_root: Option) -> PathBuf where T: AsRef { - let mut buf = fs_root.map_or(PathBuf::from("/"), |p| p.as_ref().into()); + let mut buf = fs_root.map_or_else(|| PathBuf::from("/"), |p| p.as_ref().into()); buf.push(PKG_PATH); buf } @@ -467,8 +467,8 @@ impl<'a> SvcDir<'a> { /// versions of a service that have been removed from the current /// version. pub fn purge_templated_content(&self) -> Result<()> { - for dir_path in &[svc_config_path(&self.service_name), - svc_hooks_path(&self.service_name)] + for dir_path in &[svc_config_path(self.service_name), + svc_hooks_path(self.service_name)] { debug!("Purging any old templated content from {}", dir_path.display()); @@ -502,14 +502,14 @@ impl<'a> SvcDir<'a> { Ok(()) } - fn create_svc_root(&self) -> Result<()> { Self::create_dir_all(svc_path(&self.service_name)) } + fn create_svc_root(&self) -> Result<()> { Self::create_dir_all(svc_path(self.service_name)) } /// Creates all to sub-directories in a service directory that are /// owned by the Supervisor (that is, the user the current thread /// is running as). fn create_all_sup_owned_dirs(&self) -> Result<()> { - Self::create_dir_all(svc_hooks_path(&self.service_name))?; - Self::create_dir_all(svc_logs_path(&self.service_name))?; + Self::create_dir_all(svc_hooks_path(self.service_name))?; + Self::create_dir_all(svc_logs_path(self.service_name))?; Ok(()) } @@ -521,12 +521,12 @@ impl<'a> SvcDir<'a> { /// ownership, however, they will be owned by the Supervisor /// instead. fn create_all_svc_owned_dirs(&self) -> Result<()> { - self.create_svc_owned_dir(svc_config_path(&self.service_name))?; - self.create_svc_owned_dir(svc_config_install_path(&self.service_name))?; - self.create_svc_owned_dir(svc_data_path(&self.service_name))?; - self.create_svc_owned_dir(svc_files_path(&self.service_name))?; - self.create_svc_owned_dir(svc_var_path(&self.service_name))?; - self.create_svc_owned_dir(svc_static_path(&self.service_name))?; + self.create_svc_owned_dir(svc_config_path(self.service_name))?; + self.create_svc_owned_dir(svc_config_install_path(self.service_name))?; + self.create_svc_owned_dir(svc_data_path(self.service_name))?; + self.create_svc_owned_dir(svc_files_path(self.service_name))?; + self.create_svc_owned_dir(svc_var_path(self.service_name))?; + self.create_svc_owned_dir(svc_static_path(self.service_name))?; Ok(()) } @@ -817,13 +817,13 @@ impl AtomicWriter { #[cfg(not(windows))] let permissions = *permissions; - set_permissions(&self.tempfile.path(), permissions).map_err(|e| { + set_permissions(self.tempfile.path(), permissions).map_err(|e| { io::Error::new(io::ErrorKind::Other, e.to_string()) })?; } self.tempfile.as_file().sync_all()?; - atomic_rename(self.tempfile.into_temp_path(), &self.dest.as_path())?; + atomic_rename(self.tempfile.into_temp_path(), self.dest.as_path())?; Ok(()) } @@ -980,7 +980,7 @@ mod test_find_command { PathBuf::from(".COM"), PathBuf::from(".EXE")]; let new_path = env::join_paths(path_bufs).unwrap(); - lock.set(&new_path); + lock.set(new_path); } fn setup_path() { @@ -991,7 +991,7 @@ mod test_find_command { let mut path_bufs = vec![first_path, second_path]; path_bufs.append(&mut os_paths); let new_path = env::join_paths(path_bufs).unwrap(); - env::set_var("PATH", &new_path); + env::set_var("PATH", new_path); } mod without_pathext_set { @@ -1203,7 +1203,6 @@ mod test_atomic_writer { use std::{fs::File, io::{Read, Seek, - SeekFrom, Write}}; const EXPECTED_CONTENT: &str = "A very good file format"; @@ -1235,7 +1234,7 @@ mod test_atomic_writer { let w = AtomicWriter::new(dest_file_path).expect("could not create AtomicWriter"); let res = w.with_writer(|writer| { writer.write_all(b"not the right content")?; - writer.seek(SeekFrom::Start(0))?; + writer.rewind()?; writer.write_all(EXPECTED_CONTENT.as_bytes())?; writer.flush() // not needed, just making sure we can call it }); diff --git a/components/core/src/os/ffi/windows.rs b/components/core/src/os/ffi/windows.rs index 855ca95c8f..4f2d0a8fd0 100644 --- a/components/core/src/os/ffi/windows.rs +++ b/components/core/src/os/ffi/windows.rs @@ -50,7 +50,7 @@ impl OsStrExt2 for OsStr { OsStr::from_bytes(&self.as_bytes()[i + 1..])); } } - (&*self, OsStr::from_bytes(&self.as_bytes()[self.len_()..self.len_()])) + (self, OsStr::from_bytes(&self.as_bytes()[self.len_()..self.len_()])) } fn trim_left_matches(&self, byte: u8) -> &OsStr { @@ -59,7 +59,7 @@ impl OsStrExt2 for OsStr { return OsStr::from_bytes(&self.as_bytes()[i..]); } } - &*self + self } fn split_at(&self, i: usize) -> (&OsStr, &OsStr) { diff --git a/components/core/src/os/process/exec/unix.rs b/components/core/src/os/process/exec/unix.rs index 8e5507307e..5fde3d71da 100644 --- a/components/core/src/os/process/exec/unix.rs +++ b/components/core/src/os/process/exec/unix.rs @@ -1,10 +1,13 @@ use crate::os::process::can_run_services_as_svc_user; #[cfg(not(target_os = "macos"))] use log::warn; -use nix::unistd::{setgid, - setuid, - Gid, - Uid}; +use nix::{sys::signal::{pthread_sigmask, + SigSet, + SigmaskHow}, + unistd::{setgid, + setuid, + Gid, + Uid}}; use std::{ffi::OsStr, io, os::unix::process::CommandExt, @@ -37,6 +40,17 @@ pub fn hook_command(executable: X, env: I, ids: Option<(Uid, Gid)>) with_user_and_group_information(&mut cmd, uid, gid); } + // https://github.com/rust-lang/rust/pull/101077/ drove this pre_exec call in which we we reset + // the spawned process to be able to receive all signals as this change prevented SIGTERM and 7 + // other signals from reaching processes spawned via our launcher. + unsafe { + cmd.pre_exec(|| { + let newset = SigSet::all(); + pthread_sigmask(SigmaskHow::SIG_UNBLOCK, Some(&newset), None)?; + Ok(()) + }); + } + cmd } diff --git a/components/core/src/os/process/windows.rs b/components/core/src/os/process/windows.rs index 2d14f7cbd8..f961947ed4 100644 --- a/components/core/src/os/process/windows.rs +++ b/components/core/src/os/process/windows.rs @@ -25,7 +25,7 @@ pub fn become_command(command: PathBuf, args: &[OsString]) -> Result<()> { } /// Get process identifier of calling process. -pub fn current_pid() -> u32 { unsafe { processthreadsapi::GetCurrentProcessId() as u32 } } +pub fn current_pid() -> u32 { unsafe { processthreadsapi::GetCurrentProcessId() } } pub fn handle_from_pid(pid: Pid) -> Option { unsafe { diff --git a/components/core/src/os/process/windows_child.rs b/components/core/src/os/process/windows_child.rs index e51d253462..69ebbb0bc7 100644 --- a/components/core/src/os/process/windows_child.rs +++ b/components/core/src/os/process/windows_child.rs @@ -286,7 +286,7 @@ impl Child { stderr: pipes.stderr.map(ChildStderr::from_inner), }) } - pub fn id(&self) -> u32 { unsafe { processthreadsapi::GetProcessId(self.handle.raw()) as u32 } } + pub fn id(&self) -> u32 { unsafe { processthreadsapi::GetProcessId(self.handle.raw()) } } pub fn kill(&mut self) -> io::Result<()> { cvt(unsafe { processthreadsapi::TerminateProcess(self.handle.raw(), 1) })?; diff --git a/components/core/src/os/system/linux.rs b/components/core/src/os/system/linux.rs index 42672bdb1f..7487fb9cb7 100644 --- a/components/core/src/os/system/linux.rs +++ b/components/core/src/os/system/linux.rs @@ -14,7 +14,7 @@ unsafe fn uname_libc() -> Result { if rv < 0 { let errno = errno(); - let code = errno.0 as i32; + let code = errno.0; return Err(Error::UnameFailed(format!("Error {} when calling uname: \ {}", code, errno))); diff --git a/components/core/src/package/archive.rs b/components/core/src/package/archive.rs index 6c55b671a2..e018fe0367 100644 --- a/components/core/src/package/archive.rs +++ b/components/core/src/package/archive.rs @@ -532,7 +532,7 @@ mod test { "ldflags": null, "cflags": null }); - let actual = serde_json::to_value(&info).unwrap(); + let actual = serde_json::to_value(info).unwrap(); assert_eq!(actual, expected); } diff --git a/components/core/src/package/install.rs b/components/core/src/package/install.rs index d6939ac730..dadbb01c6d 100644 --- a/components/core/src/package/install.rs +++ b/components/core/src/package/install.rs @@ -80,10 +80,10 @@ impl PackageInstall { -> Result where T: AsRef { - let fs_root_path = fs_root_path.map_or(PathBuf::from("/"), |p| p.as_ref().into()); + let fs_root_path = fs_root_path.map_or_else(|| PathBuf::from("/"), |p| p.as_ref().into()); let package_root_path = fs::pkg_root_path(Some(&fs_root_path)); if !package_root_path.exists() { - return Err(Error::PackageNotFound(ident.clone())); + return Err(Error::PackageNotFound(Box::new(ident.clone()))); } let pl = package_list_for_ident(&package_root_path, ident)?; @@ -95,7 +95,7 @@ impl PackageInstall { package_root_path, ident: ident.clone() }) } else { - Err(Error::PackageNotFound(ident.clone())) + Err(Error::PackageNotFound(Box::new(ident.clone()))) } } else { let latest: Option = @@ -121,7 +121,7 @@ impl PackageInstall { package_root_path, ident: id.clone() }) } else { - Err(Error::PackageNotFound(ident.clone())) + Err(Error::PackageNotFound(Box::new(ident.clone()))) } } } @@ -135,7 +135,7 @@ impl PackageInstall { let original_ident = ident; // If the PackageIndent is does not have a version, use a reasonable minimum version that // will be satisfied by any installed package with the same origin/name - let ident = if None == ident.version { + let ident = if ident.version.is_none() { PackageIdent::new(ident.origin.clone(), ident.name.clone(), Some("0".into()), @@ -143,10 +143,10 @@ impl PackageInstall { } else { ident.clone() }; - let fs_root_path = fs_root_path.map_or(PathBuf::from("/"), |p| p.as_ref().into()); + let fs_root_path = fs_root_path.map_or_else(|| PathBuf::from("/"), |p| p.as_ref().into()); let package_root_path = fs::pkg_root_path(Some(&fs_root_path)); if !package_root_path.exists() { - return Err(Error::PackageNotFound(original_ident.clone())); + return Err(Error::PackageNotFound(Box::new(original_ident.clone()))); } let pl = package_list_for_ident(&package_root_path, original_ident)?; @@ -177,7 +177,7 @@ impl PackageInstall { package_root_path, ident: id.clone() }) } - None => Err(Error::PackageNotFound(original_ident.clone())), + None => Err(Error::PackageNotFound(Box::new(original_ident.clone()))), } } @@ -548,7 +548,7 @@ impl PackageInstall { } } - pub fn installed_path(&self) -> &Path { &*self.installed_path } + pub fn installed_path(&self) -> &Path { &self.installed_path } /// Returns the user that the package is specified to run as /// or None if the package doesn't contain a SVC_USER Metafile @@ -773,8 +773,8 @@ mod test { let ident = PackageIdent::from_str(ident_s).unwrap(); match PackageInstall::load(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -813,8 +813,8 @@ mod test { let ident = PackageIdent::from_str("dream-theater/systematic-chaos").unwrap(); match PackageInstall::load(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -860,8 +860,8 @@ mod test { let ident = PackageIdent::from_str(ident_s).unwrap(); match PackageInstall::load(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -880,8 +880,8 @@ mod test { let ident = PackageIdent::from_str(ident_s).unwrap(); match PackageInstall::load(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -916,8 +916,8 @@ mod test { let ident = PackageIdent::from_str(ident_s).unwrap(); match PackageInstall::load_at_least(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -957,8 +957,8 @@ mod test { let ident = PackageIdent::from_str("dream-theater/systematic-chaos").unwrap(); match PackageInstall::load_at_least(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -1005,8 +1005,8 @@ mod test { let ident = PackageIdent::from_str(ident_s).unwrap(); match PackageInstall::load_at_least(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { @@ -1025,8 +1025,8 @@ mod test { let ident = PackageIdent::from_str(ident_s).unwrap(); match PackageInstall::load_at_least(&ident, Some(fs_root.path())) { - Err(Error::PackageNotFound(ref err_ident)) => { - assert_eq!(&ident, err_ident); + Err(Error::PackageNotFound(err_ident)) => { + assert_eq!(Box::new(ident), err_ident); } Err(e) => panic!("Wrong error returned, error={:?}", e), Ok(i) => { diff --git a/components/core/src/package/list.rs b/components/core/src/package/list.rs index 8fea717353..ff5b2e2607 100644 --- a/components/core/src/package/list.rs +++ b/components/core/src/package/list.rs @@ -73,7 +73,7 @@ pub fn all_packages(path: &Path) -> Result> { pub fn package_list_for_origin(base_pkg_path: &Path, origin: &str) -> Result> { let mut package_list: Vec = vec![]; let mut package_path = PathBuf::from(base_pkg_path); - package_path.push(&origin); + package_path.push(origin); if !is_existing_dir(&package_path)? { return Ok(package_list); @@ -284,7 +284,7 @@ fn filename_from_entry(entry: &fs::DirEntry) -> String { } fn is_existing_dir(path: &Path) -> Result { - match fs::metadata(&path) { + match fs::metadata(path) { Err(err) => { if err.kind() == io::ErrorKind::NotFound { return Ok(false); diff --git a/components/core/src/package/metadata.rs b/components/core/src/package/metadata.rs index 7707cce099..7b795dee58 100644 --- a/components/core/src/package/metadata.rs +++ b/components/core/src/package/metadata.rs @@ -175,7 +175,7 @@ impl fmt::Display for MetaFile { pub fn read_metafile>(installed_path: P, file: MetaFile) -> Result { match existing_metafile(installed_path, file) { Some(filepath) => { - match File::open(&filepath) { + match File::open(filepath) { Ok(mut f) => { let mut data = String::new(); if f.read_to_string(&mut data).is_err() { diff --git a/components/core/src/tls/ctl_gateway.rs b/components/core/src/tls/ctl_gateway.rs index 5e6d853a43..160c8e6267 100644 --- a/components/core/src/tls/ctl_gateway.rs +++ b/components/core/src/tls/ctl_gateway.rs @@ -70,7 +70,7 @@ pub fn generate_self_signed_certificate_and_key(subject_alternate_name: DnsNameR Ok(()) } -/// Search for files in `search_directory` that match `file_pattern` and return the last match +/// Search for files in `search_directory` that match `file_pattern` and return the last match fn get_last_path(search_directory: impl AsRef, file_pattern: &str) -> Result { let pattern = search_directory.as_ref().join(file_pattern); let pattern = pattern.to_string_lossy(); @@ -83,17 +83,17 @@ fn get_last_path(search_directory: impl AsRef, file_pattern: &str) -> Resu pub fn latest_certificates(path: impl AsRef) -> Result, Error> { let path = get_last_path(path, &format!("{}-*.{}", NAME_PREFIX, CRT_EXTENSION))?; - Ok(rustls_wrapper::certificates_from_file(&path)?) + Ok(rustls_wrapper::certificates_from_file(path)?) } pub fn latest_private_key(path: impl AsRef) -> Result { let path = get_last_path(path, &format!("{}-*.{}", NAME_PREFIX, KEY_EXTENSION))?; - Ok(rustls_wrapper::private_key_from_file(&path)?) + Ok(rustls_wrapper::private_key_from_file(path)?) } pub fn latest_root_certificate_store(path: impl AsRef) -> Result { let path = get_last_path(path, &format!("{}-*.{}", NAME_PREFIX, CRT_EXTENSION))?; - Ok(rustls_wrapper::root_certificate_store_from_file(&path)?) + Ok(rustls_wrapper::root_certificate_store_from_file(path)?) } #[cfg(test)] diff --git a/components/core/src/tls/native_tls_wrapper/readers.rs b/components/core/src/tls/native_tls_wrapper/readers.rs index 0215f30025..2caff2f15b 100644 --- a/components/core/src/tls/native_tls_wrapper/readers.rs +++ b/components/core/src/tls/native_tls_wrapper/readers.rs @@ -83,7 +83,7 @@ fn populate_cache(cache_path: &Path) -> Result<()> { if !cached_certs.exists() { debug!("Adding embedded cert file to Habitat SSL cache path {} as fallback", cached_certs.display()); - fs::create_dir_all(&cache_path)?; + fs::create_dir_all(cache_path)?; fs::write(cached_certs, CACERT_PEM)?; } Ok(()) diff --git a/components/hab/src/command/pkg/binlink.rs b/components/hab/src/command/pkg/binlink.rs index 72d82e6362..106ef27c2e 100644 --- a/components/hab/src/command/pkg/binlink.rs +++ b/components/hab/src/command/pkg/binlink.rs @@ -35,7 +35,7 @@ impl Binlink { #[cfg(unix)] { Ok(Binlink { link: path.to_path_buf(), - target: fs::read_link(&path)?, }) + target: fs::read_link(path)?, }) } #[cfg(windows)] diff --git a/components/hab/src/command/pkg/download.rs b/components/hab/src/command/pkg/download.rs index 5c65d80118..1f4c712f80 100644 --- a/components/hab/src/command/pkg/download.rs +++ b/components/hab/src/command/pkg/download.rs @@ -408,7 +408,7 @@ impl<'a> DownloadTask<'a> { // Otherwise, it might make sense to take this fetch out of the verification code. let signer = artifact::artifact_signer(&artifact.path)?; - let cache = KeyCache::new(&self.path_for_keys()); + let cache = KeyCache::new(self.path_for_keys()); cache.setup()?; if cache.public_signing_key(&signer).is_err() { diff --git a/components/hab/src/command/pkg/hash.rs b/components/hab/src/command/pkg/hash.rs index a584b518e1..9ad807654d 100644 --- a/components/hab/src/command/pkg/hash.rs +++ b/components/hab/src/command/pkg/hash.rs @@ -2,7 +2,7 @@ use crate::{error::Result, hcore::crypto::Blake2bHash}; pub fn start(src: &str) -> Result<()> { - let h = Blake2bHash::from_file(&src)?; + let h = Blake2bHash::from_file(src)?; println!("{} {}", h, src); Ok(()) } diff --git a/components/hab/src/command/pkg/search.rs b/components/hab/src/command/pkg/search.rs index 32afa7cf89..d9d70a8cb9 100644 --- a/components/hab/src/command/pkg/search.rs +++ b/components/hab/src/command/pkg/search.rs @@ -10,7 +10,7 @@ pub async fn start(st: &str, bldr_url: &str, limit: usize, token: Option<&str>) 0 => eprintln!("No packages found that match '{}'", st), _ => { for p in &packages { - if let (&Some(ref version), &Some(ref release)) = (&p.version, &p.release) { + if let (Some(version), Some(release)) = (&p.version, &p.release) { println!("{}/{}/{}/{}", p.origin, p.name, version, release); } else { println!("{}/{}", p.origin, p.name); diff --git a/components/hab/src/command/pkg/uninstall/uninstall_impl.rs b/components/hab/src/command/pkg/uninstall/uninstall_impl.rs index e2e5ad6330..7ac99b7507 100644 --- a/components/hab/src/command/pkg/uninstall/uninstall_impl.rs +++ b/components/hab/src/command/pkg/uninstall/uninstall_impl.rs @@ -265,7 +265,7 @@ fn launcher_is_running(fs_root_path: &Path) -> bool { } async fn supervisor_services() -> Result> { - if !launcher_is_running(&*FS_ROOT_PATH) { + if !launcher_is_running(&FS_ROOT_PATH) { return Ok(vec![]); } @@ -355,11 +355,11 @@ async fn maybe_delete(ui: &mut U, match strategy { ExecutionStrategy::DryRun => { - ui.status(Status::DryRunDeleting, &ident)?; + ui.status(Status::DryRunDeleting, ident)?; Ok(false) } ExecutionStrategy::Run => { - ui.status(Status::Deleting, &ident)?; + ui.status(Status::Deleting, ident)?; if uninstall_hook_mode == UninstallHookMode::Run { maybe_run_uninstall_hook(ui, install).await?; } @@ -407,7 +407,7 @@ fn do_clean_delete(pkg_root_path: &Path, real_install_path: &Path) -> Result { let temp_install_path = temp_package_directory(real_install_path)?.path() .to_path_buf(); - fs::rename(&real_install_path, &temp_install_path)?; + fs::rename(real_install_path, &temp_install_path)?; fs::remove_dir_all(&temp_install_path)?; for p in real_install_base.ancestors() { @@ -419,7 +419,7 @@ fn do_clean_delete(pkg_root_path: &Path, real_install_path: &Path) -> Result { // This will calculate the amount of items in the directory match contents.count() { - 0 => fs::remove_dir(&p)?, + 0 => fs::remove_dir(p)?, _ => break, } } diff --git a/components/hab/src/command/plan/render.rs b/components/hab/src/command/plan/render.rs index 4ab6f55308..4e4cc10c57 100644 --- a/components/hab/src/command/plan/render.rs +++ b/components/hab/src/command/plan/render.rs @@ -37,7 +37,7 @@ pub fn start(ui: &mut UI, } // read our template from file - let template = read_to_string(&template_path)?; + let template = read_to_string(template_path)?; // create a "data" json struct let mut data = json!({}); @@ -49,7 +49,7 @@ pub fn start(ui: &mut UI, // we should always have a default.toml, would be nice to "autodiscover" based on package name, // for now assume we're working in the plan dir if --default-toml not passed - let default_toml = read_to_string(&default_toml_path)?; + let default_toml = read_to_string(default_toml_path)?; // merge default into data struct merge(&mut data, toml_to_json(&default_toml)?); @@ -144,7 +144,7 @@ fn create_with_template(ui: &mut UI, template: &str, quiet: bool) -> Result<()> { - let path = Path::new(&render_dir).join(&file_name); + let path = Path::new(&render_dir).join(file_name); if !quiet { ui.status(Status::Creating, format!("file: {}", path.display()))?; } diff --git a/components/hab/src/command/studio/docker.rs b/components/hab/src/command/studio/docker.rs index e9765d0f8a..ce4fdcc310 100644 --- a/components/hab/src/command/studio/docker.rs +++ b/components/hab/src/command/studio/docker.rs @@ -54,7 +54,7 @@ pub fn start_docker_studio(_ui: &mut UI, args: &[OsString]) -> Result<()> { let local_cache_key_path = match henv::var(CACHE_KEY_PATH_ENV_VAR) { Ok(val) => PathBuf::from(val), - Err(_) => (&*CACHE_KEY_PATH).to_path_buf(), + Err(_) => (*CACHE_KEY_PATH).to_path_buf(), }; if !local_cache_key_path.exists() { return Err(Error::FileNotFound(format!("{}\nRun `hab setup` to \ diff --git a/components/hab/src/command/studio/enter.rs b/components/hab/src/command/studio/enter.rs index 258723d9ea..0e1e189b48 100644 --- a/components/hab/src/command/studio/enter.rs +++ b/components/hab/src/command/studio/enter.rs @@ -61,9 +61,9 @@ fn cache_ssl_cert_file(cert_file: &str, cert_cache_dir: &Path) -> Result<()> { Some(cert_filename) => cert_filename, None => return Err(Error::CacheSslCertError(format!("{:?} is not a file", &cert_file))), }; - let cache_file = cert_cache_dir.join(&cert_filename); + let cache_file = cert_cache_dir.join(cert_filename); - if cache_file.exists() && cert_path.exists() && is_same_file(&cache_file, &cert_path)? { + if cache_file.exists() && cert_path.exists() && is_same_file(&cache_file, cert_path)? { return Err(Error::CacheSslCertError("Source and destination certificate are the same \ file" .to_string())); @@ -376,11 +376,11 @@ mod tests { let cert_name = "ssl-test-cert.pem"; let cert_cache_dir = TempDir::new()?.into_path(); - let cached_cert = cert_cache_dir.join(&cert_name); + let cached_cert = cert_cache_dir.join(cert_name); File::create(&cached_cert)?; let ssl_cert_dir = TempDir::new()?; - let ssl_cert_filepath = ssl_cert_dir.path().join(&cert_name); + let ssl_cert_filepath = ssl_cert_dir.path().join(cert_name); std::fs::write(&ssl_cert_filepath, "new cert from environment")?; cache_ssl_cert_file(ssl_cert_filepath.to_str().unwrap(), &cert_cache_dir).unwrap(); diff --git a/components/hab/src/main.rs b/components/hab/src/main.rs index 9d0ad9b9b7..3aea07e1bb 100755 --- a/components/hab/src/main.rs +++ b/components/hab/src/main.rs @@ -868,7 +868,7 @@ fn sub_pkg_dependencies(m: &ArgMatches<'_>) -> Result<()> { } else { command::pkg::DependencyRelation::Requires }; - command::pkg::dependencies::start(&ident, scope, direction, &*FS_ROOT_PATH) + command::pkg::dependencies::start(&ident, scope, direction, &FS_ROOT_PATH) } async fn sub_pkg_download(ui: &mut UI, @@ -912,7 +912,7 @@ async fn sub_pkg_download(ui: &mut UI, fn sub_pkg_env(m: &ArgMatches<'_>) -> Result<()> { let ident = required_pkg_ident_from_input(m)?; - command::pkg::env::start(&ident, &*FS_ROOT_PATH) + command::pkg::env::start(&ident, &FS_ROOT_PATH) } fn sub_pkg_hash(m: &ArgMatches<'_>) -> Result<()> { @@ -956,7 +956,7 @@ async fn sub_pkg_uninstall(ui: &mut UI, m: &ArgMatches<'_>) -> Result<()> { command::pkg::uninstall::start(ui, &ident, - &*FS_ROOT_PATH, + &FS_ROOT_PATH, execute_strategy, mode, scope, @@ -1150,8 +1150,8 @@ async fn sub_pkg_install(ui: &mut UI, install_source, PRODUCT, VERSION, - &*FS_ROOT_PATH, - &cache_artifact_path(Some(&*FS_ROOT_PATH)), + &FS_ROOT_PATH, + &cache_artifact_path(Some(FS_ROOT_PATH.as_path())), token.as_deref(), &install_mode, &local_package_usage, @@ -1171,7 +1171,7 @@ async fn sub_pkg_install(ui: &mut UI, fn sub_pkg_path(m: &ArgMatches<'_>) -> Result<()> { let ident = required_pkg_ident_from_input(m)?; - command::pkg::path::start(&ident, &*FS_ROOT_PATH) + command::pkg::path::start(&ident, &FS_ROOT_PATH) } fn sub_pkg_list(m: &ArgMatches<'_>) -> Result<()> { @@ -1186,7 +1186,7 @@ fn sub_pkg_provides(m: &ArgMatches<'_>) -> Result<()> { let full_releases = m.is_present("FULL_RELEASES"); let full_paths = m.is_present("FULL_PATHS"); - command::pkg::provides::start(filename, &*FS_ROOT_PATH, full_releases, full_paths) + command::pkg::provides::start(filename, &FS_ROOT_PATH, full_releases, full_paths) } async fn sub_pkg_search(m: &ArgMatches<'_>) -> Result<()> { @@ -1550,7 +1550,7 @@ async fn sub_file_put(m: &ArgMatches<'_>) -> Result<()> { .map(ToString::to_string) .unwrap_or_else(|| "UKNOWN".to_string()),))?; ui.status(Status::Creating, "service file")?; - File::open(&file)?.read_to_end(&mut buf)?; + File::open(file)?.read_to_end(&mut buf)?; match (service_group.org(), user_param_or_env(m)) { (Some(_org), Some(username)) => { // That Some(_org) bit is really "was an org specified for @@ -1925,7 +1925,7 @@ fn idents_from_toml_file(ui: &mut UI, filename: &str) -> Result> ui.status(Status::Using, format!("File {}, '{}'", filename, - toml_data.file_descriptor.unwrap_or_else(|| "".to_string())))?; + toml_data.file_descriptor.unwrap_or_default()))?; for (target, target_array) in toml_data.targets { for package_set_value in target_array { diff --git a/components/hab/src/scaffolding.rs b/components/hab/src/scaffolding.rs index 02b8c7a91a..22aa015243 100644 --- a/components/hab/src/scaffolding.rs +++ b/components/hab/src/scaffolding.rs @@ -22,7 +22,7 @@ pub fn scaffold_check(ui: &mut UI, maybe_scaffold: Option<&str>) -> Result { init()?; - match scaffold.to_lowercase().as_ref() { + match scaffold.to_lowercase().as_str() { SCAFFOLDING_GO_IDENT | "go" => { let ident = PackageIdent::from_str(SCAFFOLDING_GO_IDENT)?; ui.status(Status::Using, &format!("Go Scaffolding '{}'", ident))?; @@ -68,25 +68,25 @@ fn autodiscover_scaffolding(ui: &mut UI) -> Result> { ui.para("No scaffolding type was provided. Let's see if we can figure out what kind of \ application you're planning to package.")?; let current_path = Path::new("."); - if is_project_go(¤t_path) { + 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.para("")?; Ok(Some(ident)) - } else if is_project_gradle(¤t_path) { + } 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.para("")?; Ok(Some(ident)) - } else if is_project_node(¤t_path) { + } 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.para("")?; Ok(Some(ident)) - } else if is_project_ruby(¤t_path) { + } 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))?; diff --git a/components/http-client/src/api_client.rs b/components/http-client/src/api_client.rs index 46099d0a0d..92d725b1e7 100644 --- a/components/http-client/src/api_client.rs +++ b/components/http-client/src/api_client.rs @@ -92,7 +92,7 @@ impl ApiClient { client = habitat_core::tls::native_tls_wrapper::certificates_as_der(fs_root_path)? .into_iter() - .map(|raw| ReqwestCertificate::from_der(&*raw)) + .map(|raw| ReqwestCertificate::from_der(&raw)) .collect::, _>>()? .into_iter() .fold(client, |client, cert| { diff --git a/components/launcher/src/error.rs b/components/launcher/src/error.rs index df6fb980ee..adb66dd992 100644 --- a/components/launcher/src/error.rs +++ b/components/launcher/src/error.rs @@ -3,15 +3,16 @@ use std::io; use thiserror::Error; #[derive(Debug, Error)] +#[warn(clippy::result_large_err)] pub enum ServiceRunError { #[error("Failed to spawn service process")] Spawn(#[source] io::Error), #[cfg(unix)] #[error("Failed to determine UID for user '{0}'")] - GetUid(String, #[source] habitat_core::Error), + GetUid(String, #[source] habitat_core::Error), // JAH: GetUid largest variant >= 128 bytes #[cfg(unix)] #[error("Failed to determine GID for group '{0}'")] - GetGid(String, #[source] habitat_core::Error), + GetGid(String, #[source] habitat_core::Error), // JAH: GetGid largest variant >= 128 bytes #[cfg(windows)] #[error("Failed to determine current username")] GetCurrentUsername(#[source] habitat_core::Error), diff --git a/components/launcher/src/sys/windows/service.rs b/components/launcher/src/sys/windows/service.rs index bd527988b6..b180cc2f3b 100644 --- a/components/launcher/src/sys/windows/service.rs +++ b/components/launcher/src/sys/windows/service.rs @@ -46,7 +46,7 @@ impl Process { last_status: None } } - pub fn id(&self) -> u32 { unsafe { processthreadsapi::GetProcessId(self.handle.raw()) as u32 } } + pub fn id(&self) -> u32 { unsafe { processthreadsapi::GetProcessId(self.handle.raw()) } } /// Attempt to gracefully terminate a process and then forcefully kill it after /// 8 seconds if it has not terminated. @@ -152,7 +152,7 @@ pub fn run(msg: protocol::Spawn) -> Result { let new_env = msg.env.clone().into_iter().collect(); - match util::spawn_pwsh(&ps_cmd, &new_env, &user, password) { + match util::spawn_pwsh(&ps_cmd, &new_env, user, password) { Ok(child) => { let process = Process::new(child.handle); Ok(Service::new(msg, process, child.stdout, child.stderr)) diff --git a/components/pkg-export-container/src/build.rs b/components/pkg-export-container/src/build.rs index 101c72cb5b..a77a9f8bb4 100644 --- a/components/pkg-export-container/src/build.rs +++ b/components/pkg-export-container/src/build.rs @@ -387,7 +387,7 @@ impl BuildSpec { url, channel, &install_source, - &*PROGRAM_NAME, + &PROGRAM_NAME, VERSION, fs_root_path, &cache_artifact_path(Some(&fs_root_path)), diff --git a/components/pkg-export-container/src/cli.rs b/components/pkg-export-container/src/cli.rs index fa1a176bc8..744756ba89 100644 --- a/components/pkg-export-container/src/cli.rs +++ b/components/pkg-export-container/src/cli.rs @@ -15,7 +15,7 @@ const VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/VERSION")); /// Create the Clap CLI for the container exporter pub fn cli<'a, 'b>() -> App<'a, 'b> { - let name: &str = &*PROGRAM_NAME; + let name: &str = &PROGRAM_NAME; let about = "Creates a container image from a set of Habitat packages (and optionally pushes \ to a remote repository)"; diff --git a/components/pkg-export-container/src/container.rs b/components/pkg-export-container/src/container.rs index 50f9aaa939..0707ed37a4 100644 --- a/components/pkg-export-container/src/container.rs +++ b/components/pkg-export-container/src/container.rs @@ -180,7 +180,7 @@ impl BuildContext { { let file = "etc/passwd"; let mut f = OpenOptions::new().append(true) - .open(ctx.rootfs().join(&file))?; + .open(ctx.rootfs().join(file))?; for user in users { ui.status(Status::Creating, format!("user '{}' in /{}", user.name, &file))?; @@ -190,7 +190,7 @@ impl BuildContext { { let file = "etc/group"; let mut f = OpenOptions::new().append(true) - .open(ctx.rootfs().join(&file))?; + .open(ctx.rootfs().join(file))?; for group in groups { ui.status(Status::Creating, format!("group '{}' in /{}", group.name, &file))?; diff --git a/components/pkg-export-container/src/engine/buildah.rs b/components/pkg-export-container/src/engine/buildah.rs index 9b76508aa3..c6663ce990 100644 --- a/components/pkg-export-container/src/engine/buildah.rs +++ b/components/pkg-export-container/src/engine/buildah.rs @@ -64,24 +64,24 @@ impl Engine for BuildahEngine { /// `buildah images -q mycompany/coolapp` fn image_id_command(&self, image_reference: &str) -> Command { let mut cmd = Command::new(&self.binary); - cmd.args(&["images", "-q", image_reference]); + cmd.args(["images", "-q", image_reference]); cmd } /// `buildah rmi mycompany/coolapp` fn image_removal_command(&self, image_reference: &str) -> Command { let mut cmd = Command::new(&self.binary); - cmd.args(&["rmi", image_reference]); + cmd.args(["rmi", image_reference]); cmd } /// `buildah push --authfile=/path/to/local/config.json push mycompany/mycoolapp` fn image_push_command(&self, image_reference: &str, config_dir: &Path) -> Command { let mut cmd = Command::new(&self.binary); - cmd.args(&["push", - "--authfile", - &config_dir.join("config.json").to_string_lossy(), - image_reference]); + cmd.args(["push", + "--authfile", + &config_dir.join("config.json").to_string_lossy(), + image_reference]); cmd } @@ -105,7 +105,7 @@ impl Engine for BuildahEngine { // (This is only really a problem when *pushing* images, but // since DockerHub is the 800 lb gorilla, we'll defer to it // for now.) - cmd.args(&["--format", "docker"]); + cmd.args(["--format", "docker"]); // Have to override the policy file location because we don't // control /etc/containers/policy.json @@ -116,7 +116,7 @@ impl Engine for BuildahEngine { cmd.arg("--memory").arg(mem); } for tag in tags { - cmd.arg("--tag").arg(&tag); + cmd.arg("--tag").arg(tag); } cmd.arg("."); cmd diff --git a/components/pkg-export-container/src/engine/docker.rs b/components/pkg-export-container/src/engine/docker.rs index 83f4e4756e..398160e862 100644 --- a/components/pkg-export-container/src/engine/docker.rs +++ b/components/pkg-export-container/src/engine/docker.rs @@ -22,24 +22,24 @@ impl Engine for DockerEngine { /// `docker images -q mycompany/coolapp` fn image_id_command(&self, image_reference: &str) -> Command { let mut cmd = Command::new(&self.binary); - cmd.args(&["images", "-q", image_reference]); + cmd.args(["images", "-q", image_reference]); cmd } /// `docker rmi mycompany/coolapp` fn image_removal_command(&self, image_reference: &str) -> Command { let mut cmd = Command::new(&self.binary); - cmd.args(&["rmi", image_reference]); + cmd.args(["rmi", image_reference]); cmd } /// `docker --config /path/to/local/config push mycompany/mycoolapp` fn image_push_command(&self, image_reference: &str, config_dir: &Path) -> Command { let mut cmd = Command::new(&self.binary); - cmd.args(&["--config", - &config_dir.to_string_lossy(), - "push", - image_reference]); + cmd.args(["--config", + &config_dir.to_string_lossy(), + "push", + image_reference]); cmd } @@ -58,7 +58,7 @@ impl Engine for DockerEngine { cmd.arg("--memory").arg(mem); } for tag in tags { - cmd.arg("--tag").arg(&tag); + cmd.arg("--tag").arg(tag); } cmd.arg("."); cmd diff --git a/components/pkg-export-container/src/lib.rs b/components/pkg-export-container/src/lib.rs index ab442d7201..dff936975e 100644 --- a/components/pkg-export-container/src/lib.rs +++ b/components/pkg-export-container/src/lib.rs @@ -118,8 +118,8 @@ impl Credentials { Ok(Credentials { token }) } RegistryType::Docker | RegistryType::Azure => { - Ok(Credentials { token: habitat_core::base64::encode(&format!("{}:{}", - username, password)), }) + Ok(Credentials { token: habitat_core::base64::encode(format!("{}:{}", + username, password)), }) } } } @@ -243,6 +243,6 @@ fn create_docker_config_file(credentials: &Credentials, } }); - util::write_file(&config, &serde_json::to_string(&json).unwrap())?; + util::write_file(config, &serde_json::to_string(&json).unwrap())?; Ok(()) } diff --git a/components/pkg-export-tar/src/build.rs b/components/pkg-export-tar/src/build.rs index 25249c1f71..4af029171b 100644 --- a/components/pkg-export-tar/src/build.rs +++ b/components/pkg-export-tar/src/build.rs @@ -102,14 +102,14 @@ impl<'a> BuildSpec<'a> { async fn prepare_rootfs(&self, ui: &mut UI, rootfs: &Path) -> Result { ui.status(Status::Creating, "root filesystem")?; - rootfs::create(&rootfs)?; - self.create_symlink_to_artifact_cache(ui, &rootfs)?; - self.create_symlink_to_key_cache(ui, &rootfs)?; + rootfs::create(rootfs)?; + self.create_symlink_to_artifact_cache(ui, rootfs)?; + self.create_symlink_to_key_cache(ui, rootfs)?; self.install_base_pkgs(ui, rootfs).await?; let ident = self.install_user_pkg(ui, self.ident_or_archive, rootfs) .await?; - self.remove_symlink_to_key_cache(ui, &rootfs)?; - self.remove_symlink_to_artifact_cache(ui, &rootfs)?; + self.remove_symlink_to_key_cache(ui, rootfs)?; + self.remove_symlink_to_artifact_cache(ui, rootfs)?; Ok(ident) } @@ -219,7 +219,7 @@ impl<'a> BuildSpec<'a> { url, channel, &install_source, - &*PROGRAM_NAME, + &PROGRAM_NAME, VERSION, fs_root_path, &cache_artifact_path(Some(&fs_root_path)), diff --git a/components/pkg-export-tar/src/main.rs b/components/pkg-export-tar/src/main.rs index 7b7182ec84..170d6c3336 100644 --- a/components/pkg-export-tar/src/main.rs +++ b/components/pkg-export-tar/src/main.rs @@ -27,7 +27,7 @@ async fn start(ui: &mut UI) -> Result<()> { } fn cli<'a, 'b>() -> App<'a, 'b> { - let name: &str = &*PROGRAM_NAME; + let name: &str = &PROGRAM_NAME; let about = "Creates a tar package from a Habitat package"; Cli::new(name, about).add_base_packages_args() .add_builder_args() diff --git a/components/sup/src/ctl_gateway/server.rs b/components/sup/src/ctl_gateway/server.rs index c465142805..bf3149354e 100644 --- a/components/sup/src/ctl_gateway/server.rs +++ b/components/sup/src/ctl_gateway/server.rs @@ -134,9 +134,10 @@ pub struct CtlCommand { // // https://github.com/rust-lang/rust/issues/28796 // - // This is now possible see https://github.com/habitat-sh/habitat/issues/6832 + // TODO: This is now possible see https://github.com/habitat-sh/habitat/issues/6832 // We held off on making the change to reduce the risk of a regression and to lump it in with // more general Future refactoring. + #[allow(clippy::type_complexity)] fun: Box NetResult<()> + Send>, } diff --git a/components/sup/src/http_gateway.rs b/components/sup/src/http_gateway.rs index 75b2dd23de..86ca909c8f 100644 --- a/components/sup/src/http_gateway.rs +++ b/components/sup/src/http_gateway.rs @@ -278,7 +278,7 @@ impl Server { control: Arc<(Mutex, Condvar)>) { thread::spawn(move || { debug!("Entering http_gateway run thread"); - let &(ref lock, ref cvar) = &*control; + let (lock, cvar) = &*control; let thread_count = match henv::var(HTTP_THREADS_ENVVAR) { Ok(val) => { match val.parse::() { @@ -437,10 +437,10 @@ fn health_gsr(svc: String, group: String, org: Option<&str>, state: &AppState) - let http_status: StatusCode = health_check.into(); body.status = health_check.to_string(); - if let Ok(mut file) = File::open(&stdout_path) { + if let Ok(mut file) = File::open(stdout_path) { let _ = file.read_to_string(&mut body.stdout); } - if let Ok(mut file) = File::open(&stderr_path) { + if let Ok(mut file) = File::open(stderr_path) { let _ = file.read_to_string(&mut body.stderr); } diff --git a/components/sup/src/manager.rs b/components/sup/src/manager.rs index b7bde2994a..fb063cee8a 100644 --- a/components/sup/src/manager.rs +++ b/components/sup/src/manager.rs @@ -355,7 +355,7 @@ impl ManagerConfig { // JC: This mimics the logic from when we had composites. But // should we check for Err ? - ServiceSpec::from_file(&spec_file).ok() + ServiceSpec::from_file(spec_file).ok() } } @@ -713,7 +713,7 @@ impl Manager { let cfg_static = cfg.clone(); let self_updater = if cfg.auto_update { if THIS_SUPERVISOR_IDENT.fully_qualified() { - Some(SelfUpdater::new(&*THIS_SUPERVISOR_IDENT, + Some(SelfUpdater::new(&THIS_SUPERVISOR_IDENT, cfg.update_url, cfg.update_channel, cfg.auto_update_period)) @@ -844,7 +844,7 @@ impl Manager { fn clean_dirty_state(fs_cfg: &FsCfg) -> Result<()> { let data_path = &fs_cfg.data_path; debug!("Cleaning cached health checks"); - match fs::read_dir(&data_path) { + match fs::read_dir(data_path) { Ok(entries) => { for entry in entries.flatten() { match entry.path().extension().and_then(OsStr::to_str) { @@ -866,12 +866,12 @@ impl Manager { fn create_state_path_dirs(fs_cfg: &FsCfg) -> Result<()> { let data_path = &fs_cfg.data_path; debug!("Creating data directory: {}", data_path.display()); - if let Some(err) = fs::create_dir_all(&data_path).err() { + if let Some(err) = fs::create_dir_all(data_path).err() { return Err(Error::BadDataPath(data_path.clone(), err)); } let specs_path = &fs_cfg.specs_path; debug!("Creating specs directory: {}", specs_path.display()); - if let Some(err) = fs::create_dir_all(&specs_path).err() { + if let Some(err) = fs::create_dir_all(specs_path).err() { return Err(Error::BadSpecsPath(specs_path.clone(), err)); } @@ -1114,12 +1114,12 @@ impl Manager { // is possible to have no versions installed if a development build is being run. if let Some(latest) = pkg::installed(&*THIS_SUPERVISOR_FUZZY_IDENT) { if *THIS_SUPERVISOR_IDENT == latest.ident { - self.maybe_uninstall_old_packages(&*THIS_SUPERVISOR_FUZZY_IDENT) + self.maybe_uninstall_old_packages(&THIS_SUPERVISOR_FUZZY_IDENT) .await; } } - let &(ref lock, ref cvar) = &*pair; + let (lock, cvar) = &*pair; let mut started = lock.lock().expect("Control mutex is poisoned"); // This will block the current thread until the HTTP gateway thread either starts diff --git a/components/sup/src/manager/file_watcher.rs b/components/sup/src/manager/file_watcher.rs index 33df184044..ec0f07f6a6 100644 --- a/components/sup/src/manager/file_watcher.rs +++ b/components/sup/src/manager/file_watcher.rs @@ -1155,7 +1155,7 @@ mod tests { /// Creates and syncs a file. The containing directory shuold exist before calling. pub fn create_file(path: &Path) -> io::Result { - let file = std::fs::File::create(&path)?; + let file = std::fs::File::create(path)?; file.sync_all()?; Ok(file) } diff --git a/components/sup/src/manager/service.rs b/components/sup/src/manager/service.rs index 6e26dcbbe7..ae1e1dffc9 100644 --- a/components/sup/src/manager/service.rs +++ b/components/sup/src/manager/service.rs @@ -559,11 +559,11 @@ impl Service { Service { spec, sys, cfg, - config_renderer: CfgRenderer::new(&config_root)?, + config_renderer: CfgRenderer::new(config_root)?, health_check_result: Arc::new(Mutex::new(HealthCheckResult::Unknown)), hooks: HookTable::load(&pkg.name, - &hooks_root, - svc_hooks_path(&service_group.service()), + hooks_root, + svc_hooks_path(service_group.service()), feature_flags), last_election_status: ElectionStatus::None, user_config_updated: false, @@ -1268,7 +1268,7 @@ impl Service { match self.hooks.run { Some(ref hook) => { fs::copy(hook.path(), &svc_run)?; - Self::set_hook_permissions(&svc_run.to_str().unwrap())?; + Self::set_hook_permissions(svc_run.to_str().unwrap())?; } None => { let run = self.pkg.path.join(hooks::RunHook::FILE_NAME); @@ -1478,7 +1478,7 @@ impl Service { None } }; - let new_checksum = Blake2bHash::from_bytes(&contents); + let new_checksum = Blake2bHash::from_bytes(contents); if let Some(current_checksum) = current_checksum { if new_checksum == current_checksum { diff --git a/components/sup/src/manager/service/hooks.rs b/components/sup/src/manager/service/hooks.rs index 4b97ceb32b..f3d4765b44 100644 --- a/components/sup/src/manager/service/hooks.rs +++ b/components/sup/src/manager/service/hooks.rs @@ -71,7 +71,7 @@ impl Hook for FileUpdatedHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, _: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, _: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { status.success() } @@ -157,11 +157,11 @@ impl Hook for HealthCheckHook { } } - fn handle_exit<'a>(&self, - pkg: &Pkg, - hook_output: &'a HookOutput, - status: ExitStatus) - -> Self::ExitValue { + fn handle_exit(&self, + pkg: &Pkg, + hook_output: &HookOutput, + status: ExitStatus) + -> Self::ExitValue { if status.code().is_none() { Self::output_termination_message(&pkg.name, status); } @@ -195,7 +195,7 @@ impl Hook for InitHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { let pkg_name = &pkg.name; match status.code() { Some(0) => true, @@ -246,7 +246,7 @@ impl Hook for RunHook { run by the Supervisor module!"); } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { match status.code() { Some(code) => ExitCode(code), None => { @@ -283,7 +283,7 @@ impl Hook for PostRunHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { match status.code() { Some(code) => ExitCode(code), None => { @@ -326,7 +326,7 @@ impl Hook for ReloadHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { let pkg_name = &pkg.name; match status.code() { Some(0) => ExitCode(0), @@ -369,7 +369,7 @@ impl Hook for ReconfigureHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { match status.code() { Some(code) => ExitCode(code), None => { @@ -433,11 +433,11 @@ impl Hook for SuitabilityHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, - pkg: &Pkg, - hook_output: &'a HookOutput, - status: ExitStatus) - -> Self::ExitValue { + fn handle_exit(&self, + pkg: &Pkg, + hook_output: &HookOutput, + status: ExitStatus) + -> Self::ExitValue { let pkg_name = &pkg.name; match status.code() { Some(0) => { @@ -489,7 +489,7 @@ impl Hook for PostStopHook { stderr_log_path: hooks::stderr_log_path::(package_name), } } - fn handle_exit<'a>(&self, pkg: &Pkg, _: &'a HookOutput, status: ExitStatus) -> Self::ExitValue { + fn handle_exit(&self, pkg: &Pkg, _: &HookOutput, status: ExitStatus) -> Self::ExitValue { let pkg_name = &pkg.name; match status.code() { Some(0) => true, @@ -852,16 +852,16 @@ mod tests { assert!(hook_table.compile(&service_group, &ctx).changed()); // Verify init hook - let init_hook_content = file_content(&hook_table.init - .as_ref() - .map(convert::AsRef::as_ref) - .expect("no init hook??")); + let init_hook_content = file_content(hook_table.init + .as_ref() + .map(convert::AsRef::as_ref) + .expect("no init hook??")); let expected_init_hook = "#!/bin/bash\n\necho \"The message is Hello\"\n"; let expected_run_hook = "#!/bin/bash\n\necho \"Running a program\"\n"; assert_eq!(init_hook_content, expected_init_hook); // Verify run hook - let run_hook_content = file_content(&hook_table.run.as_ref().expect("no run hook??")); + let run_hook_content = file_content(hook_table.run.as_ref().expect("no run hook??")); assert_eq!(run_hook_content, expected_run_hook); // Recompiling again results in no changes @@ -875,7 +875,7 @@ mod tests { assert_eq!(init_hook_content, expected_init_hook); // Re-Verify run hook - let run_hook_content = file_content(&hook_table.run.as_ref().expect("no run hook??")); + let run_hook_content = file_content(hook_table.run.as_ref().expect("no run hook??")); assert_eq!(run_hook_content, expected_run_hook); } @@ -916,7 +916,7 @@ mod tests { let tmp_root = rendered_hooks_path().into_path(); let hooks_path = tmp_root.clone().join("hooks"); fs::create_dir_all(&hooks_path).unwrap(); - fs::create_dir_all(svc_logs_path(&service_group.service())).unwrap(); + fs::create_dir_all(svc_logs_path(service_group.service())).unwrap(); let concrete_path = hooks_path.clone(); let template_path = hook_templates_path(); @@ -962,7 +962,7 @@ mod tests { let tmp_root = rendered_hooks_path().into_path(); let hooks_path = tmp_root.clone().join("hooks"); fs::create_dir_all(&hooks_path).unwrap(); - fs::create_dir_all(svc_logs_path(&service_group.service())).unwrap(); + fs::create_dir_all(svc_logs_path(service_group.service())).unwrap(); let concrete_path = hooks_path.clone(); let template_path = hook_templates_path(); let mut flags = FeatureFlag::empty(); diff --git a/components/sup/src/manager/service/pipe_hook_client.rs b/components/sup/src/manager/service/pipe_hook_client.rs index 9b56bde576..88d69ce9e9 100644 --- a/components/sup/src/manager/service/pipe_hook_client.rs +++ b/components/sup/src/manager/service/pipe_hook_client.rs @@ -271,11 +271,11 @@ impl Drop for PipeHookClient { fn stream_output(out: T, log_file: &Path, preamble_str: &str) where T: Read { - File::create(&log_file).unwrap_or_else(|_| { - panic!("{}: couldn't create log output file {}", - preamble_str, - &log_file.to_string_lossy()) - }); + File::create(log_file).unwrap_or_else(|_| { + panic!("{}: couldn't create log output file {}", + preamble_str, + &log_file.to_string_lossy()) + }); for line in BufReader::new(out).lines_lossy().flatten() { outputln!(preamble preamble_str, &line); @@ -284,7 +284,7 @@ fn stream_output(out: T, log_file: &Path, preamble_str: &str) // truncate the log on each hook execution so that the log only // holds the output of the last run. This mimics the behavior of // the HookOutput streaming. - match OpenOptions::new().write(true).append(true).open(&log_file) { + match OpenOptions::new().write(true).append(true).open(log_file) { Ok(mut log) => { if let Err(e) = writeln!(log, "{}", line) { outputln!(preamble preamble_str, "couldn't write line. {}", e); @@ -336,7 +336,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_returns_exit_status() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "exit 5000"); @@ -355,7 +355,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_returns_exit_status_when_no_exit_in_script() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "write-host 'no exit here'"); @@ -374,7 +374,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_logs_stdout() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "Write-Host 'you are my sunshine'"); @@ -396,7 +396,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_logs_stderr() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "Write-Error 'you are not my sunshine'"); @@ -418,7 +418,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_shares_server_accross_calls() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "exit $PID"); @@ -508,7 +508,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_starts_new_service_if_current_instance_exits() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "exit $PID"); @@ -535,7 +535,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_restores_environment() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, @@ -558,7 +558,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_drop_quits_service() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "exit $PID"); @@ -583,7 +583,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_will_return_3_if_hook_throws_exception() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "throw 'an exception'"); @@ -602,7 +602,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_clears_stdout_log() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "write-host 'you should only see me once in the log'"); @@ -627,7 +627,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_clears_stderr_log() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "write-error 'I am the only error'"); @@ -653,7 +653,7 @@ mod test { #[tokio::test] async fn pipe_hook_client_exec_hook_passes_pid() { let var = pipe_service_path(); - var.set(&named_pipe_service_ps1()); + var.set(named_pipe_service_ps1()); let tmpdir = TempDir::new().unwrap(); let path = tmpdir.path().join("health-check"); create_with_content(&path, "exit $ParentPID"); diff --git a/components/sup/src/manager/service/supervisor.rs b/components/sup/src/manager/service/supervisor.rs index 3b7c364ecf..ade4c9c336 100644 --- a/components/sup/src/manager/service/supervisor.rs +++ b/components/sup/src/manager/service/supervisor.rs @@ -127,7 +127,7 @@ impl Supervisor { if self.pid_source == ServicePidSource::Files { read_pid(&self.pid_file) } else { - match launcher.pid_of(&self.service_group.to_string()) { + match launcher.pid_of(&self.service_group) { Ok(maybe_pid) => maybe_pid, Err(err) => { error!("Error getting pid from launcher: {:#}", diff --git a/components/sup/src/manager/service_updater/rolling_update_worker.rs b/components/sup/src/manager/service_updater/rolling_update_worker.rs index ec5799b0ff..ab21e6eec6 100644 --- a/components/sup/src/manager/service_updater/rolling_update_worker.rs +++ b/components/sup/src/manager/service_updater/rolling_update_worker.rs @@ -269,7 +269,7 @@ impl RollingUpdateWorker { FollowerUpdateStartEvent::PromotedToLeader => { return FollowerUpdateTurnEvent::PromotedToLeader } - FollowerUpdateStartEvent::UpdateTo(ident) => (ident), + FollowerUpdateStartEvent::UpdateTo(ident) => ident, }; loop { { diff --git a/components/sup/src/manager/spec_watcher.rs b/components/sup/src/manager/spec_watcher.rs index c519eb351f..fe2a801ac6 100644 --- a/components/sup/src/manager/spec_watcher.rs +++ b/components/sup/src/manager/spec_watcher.rs @@ -154,7 +154,7 @@ mod tests { where C: Into { let path = dir.path().join(filename); - let mut buffer = File::create(&path)?; + let mut buffer = File::create(path)?; buffer.write_all(contents.into().as_bytes()) } diff --git a/components/sup/src/manager/user_config_watcher.rs b/components/sup/src/manager/user_config_watcher.rs index 8000458e8f..147725784a 100644 --- a/components/sup/src/manager/user_config_watcher.rs +++ b/components/sup/src/manager/user_config_watcher.rs @@ -343,7 +343,7 @@ mod tests { ucm.add(&service).expect("adding service"); assert!(wait_for_watcher(&ucm, &service)); - let mut file = File::create(&file_path).expect("creating file"); + let mut file = File::create(file_path).expect("creating file"); file.write_all(b"42").expect(USER_CONFIG_FILE); @@ -361,7 +361,7 @@ mod tests { ucm.add(&service).expect("adding service"); assert!(wait_for_watcher(&ucm, &service)); - let mut file = File::create(&file_path).expect("creating file"); + let mut file = File::create(file_path).expect("creating file"); file.write_all(b"42").expect(USER_CONFIG_FILE); diff --git a/components/sup/src/sys/windows/service.rs b/components/sup/src/sys/windows/service.rs index 2c2c1ebc50..579f8dd286 100644 --- a/components/sup/src/sys/windows/service.rs +++ b/components/sup/src/sys/windows/service.rs @@ -55,7 +55,7 @@ impl Process { last_status: None } } - fn id(&self) -> u32 { unsafe { processthreadsapi::GetProcessId(self.handle.raw()) as u32 } } + fn id(&self) -> u32 { unsafe { processthreadsapi::GetProcessId(self.handle.raw()) } } /// Attempt to gracefully terminate a process and then forcefully kill it after /// 8 seconds if it has not terminated. diff --git a/components/sup/src/util/pkg.rs b/components/sup/src/util/pkg.rs index 96f70b19ea..dc1d50446e 100644 --- a/components/sup/src/util/pkg.rs +++ b/components/sup/src/util/pkg.rs @@ -132,7 +132,7 @@ pub async fn uninstall_all_but_latest(ident: impl AsRef, uninstall::uninstall_all_but_latest(&mut NullUi::new(), ident, number_latest_to_keep, - &*FS_ROOT_PATH, + &FS_ROOT_PATH, pkg::ExecutionStrategy::Run, pkg::Scope::PackageAndDependencies, &[], @@ -148,7 +148,7 @@ pub async fn uninstall_all_but_latest(ident: impl AsRef, pub async fn uninstall_even_if_loaded(ident: impl AsRef) -> HabResult<()> { uninstall::uninstall(&mut NullUi::new(), &ident.as_ref(), - &*FS_ROOT_PATH, + &FS_ROOT_PATH, pkg::ExecutionStrategy::Run, pkg::Scope::PackageAndDependencies, &[], diff --git a/components/sup/tests/utils/test_sup.rs b/components/sup/tests/utils/test_sup.rs index f029792aab..c5ca081a35 100644 --- a/components/sup/tests/utils/test_sup.rs +++ b/components/sup/tests/utils/test_sup.rs @@ -278,7 +278,7 @@ impl TestSup { let launcher_exe = find_exe("hab-launch").context("Failed to find 'hab-launch' executable")?; - let mut cmd = Command::new(&launcher_exe); + let mut cmd = Command::new(launcher_exe); let listen_host = "0.0.0.0"; cmd.env( diff --git a/components/win-users/src/sid.rs b/components/win-users/src/sid.rs index 3dee0f8c6e..3565e53003 100644 --- a/components/win-users/src/sid.rs +++ b/components/win-users/src/sid.rs @@ -172,7 +172,7 @@ impl Sid { let mut buffer = Vec::>::with_capacity(dw_buffer_size as usize); buffer.set_len(dw_buffer_size as usize); - let p_token_user: PTOKEN_USER = std::mem::transmute_copy(&buffer); + let p_token_user = buffer.as_mut_ptr() as PTOKEN_USER; cvt(GetTokenInformation(token, TokenUser, @@ -308,9 +308,9 @@ impl Sid { // TODO JB: fix this clippy #[allow(clippy::cast_ptr_alignment)] let psize_info = &mut *(acl_size_buf.as_mut_ptr() as *mut ACL_SIZE_INFORMATION); - size_info.aceCount = (*psize_info).aceCount; - size_info.aclBytesInUse = (*psize_info).aclBytesInUse; - size_info.aclBytesFree = (*psize_info).aclBytesFree; + size_info.aceCount = (psize_info).aceCount; + size_info.aclBytesInUse = (psize_info).aclBytesInUse; + size_info.aclBytesFree = (psize_info).aclBytesFree; } let psid_length = GetLengthSid(self.raw.as_ptr() as PSID); diff --git a/rust-toolchain b/rust-toolchain index b77a81dcb1..737e2ba509 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.62.1 +1.67.1 diff --git a/support/denied_lints.txt b/support/denied_lints.txt index 2bd821f76b..5a6dbcaa16 100644 --- a/support/denied_lints.txt +++ b/support/denied_lints.txt @@ -1,5 +1,4 @@ clippy::assign_op_pattern -clippy::blacklisted_name clippy::blocks_in_if_conditions clippy::bool_comparison clippy::cast_lossless @@ -10,6 +9,7 @@ clippy::collapsible_if clippy::correctness clippy::cognitive_complexity clippy::deref_addrof +clippy::disallowed_names clippy::expect_fun_call clippy::filter_map_next clippy::for_kv_map