From 6c1ea7621eecf722bb64fb61efa9aa96dd693fe6 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Fri, 19 Sep 2025 17:36:04 +0000 Subject: [PATCH] fix: avoid strict argument evaluation to .then_some An instance of `.then_some` on a bool caused an error because `.then_some` takes a 'T' as an argument, and is thus evaluated strictly; an error in the resulting eager evaluation caused an error return, regardless of whether the predicating boolean was true or not. Nominally, using `.then` would have fixed it, but one cannot conveniently use `?` in a closure, which the code we wanted to run did. So switch to a good 'ol `if` expression instead. In testing, all of our configurations had the file we were testing the presence of before reading. But other folks do not. However, one cannot conveniently use `?` in a closure in this context, so Fixes #9051 --- sled-agent/src/bin/sled-agent.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sled-agent/src/bin/sled-agent.rs b/sled-agent/src/bin/sled-agent.rs index 27e4059bd09..19094301b8d 100644 --- a/sled-agent/src/bin/sled-agent.rs +++ b/sled-agent/src/bin/sled-agent.rs @@ -62,13 +62,18 @@ async fn do_run() -> Result<(), CmdError> { rss_config_path.push("config-rss.toml"); rss_config_path }; - let rss_config = rss_config_path.exists().then_some({ + let rss_config = if rss_config_path.exists() { let rss_config = RackInitializeRequest::from_file(rss_config_path) .map_err(|e| CmdError::Failure(anyhow!(e)))?; let skip_timesync = config.skip_timesync.unwrap_or(false); - RackInitializeRequestParams::new(rss_config, skip_timesync) - }); + Some(RackInitializeRequestParams::new( + rss_config, + skip_timesync, + )) + } else { + None + }; let server = bootstrap_server::Server::start(config) .await