From ecd40aa02e93d710759cf34f09fd1647a46728d6 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Wed, 25 Sep 2024 00:00:30 -0700 Subject: [PATCH] --- insta/src/env.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/insta/src/env.rs b/insta/src/env.rs index 7b2bed18..363a908d 100644 --- a/insta/src/env.rs +++ b/insta/src/env.rs @@ -17,13 +17,11 @@ lazy_static::lazy_static! { pub fn get_tool_config(manifest_dir: &str) -> Arc { let mut configs = TOOL_CONFIGS.lock().unwrap(); - if let Some(rv) = configs.get(manifest_dir) { - return rv.clone(); - } - let config = - Arc::new(ToolConfig::from_manifest_dir(manifest_dir).expect("failed to load tool config")); - configs.insert(manifest_dir.to_string(), config.clone()); - config + + configs + .entry(manifest_dir.to_string()) + .or_insert_with(|| Arc::new(ToolConfig::from_manifest_dir(manifest_dir).unwrap())) + .clone() } /// The test runner to use. @@ -411,7 +409,8 @@ pub fn snapshot_update_behavior(tool_config: &ToolConfig, unseen: bool) -> Snaps /// Returns the cargo workspace for a manifest pub fn get_cargo_workspace(manifest_dir: &str) -> Arc { - let mut workspaces = WORKSPACES.lock().expect("Failed to lock WORKSPACES"); + // we really do not care about poisoning here. + let mut workspaces = WORKSPACES.lock().unwrap(); workspaces .entry(manifest_dir.to_string())