From 54fd6e0c01b770e39bf1d4fe0ff9d499d6700055 Mon Sep 17 00:00:00 2001
From: Vincent Lafeychine <vincent.lafeychine@proton.me>
Date: Fri, 10 May 2024 11:47:43 +0200
Subject: [PATCH] clippy: Fix create_dir

---
 rr_frontend/.cargo/config.toml     | 1 -
 rr_frontend/translation/src/lib.rs | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml
index 46e4728d..986cb351 100644
--- a/rr_frontend/.cargo/config.toml
+++ b/rr_frontend/.cargo/config.toml
@@ -32,7 +32,6 @@ rustflags = [
     "-Aclippy::string_lit_as_bytes",
 
     # clippy::restriction
-    "-Aclippy::create_dir",
     "-Aclippy::empty_structs_with_brackets",
     "-Aclippy::get_unwrap",
     "-Aclippy::if_then_some_else_none",
diff --git a/rr_frontend/translation/src/lib.rs b/rr_frontend/translation/src/lib.rs
index b10a5478..2b25d754 100644
--- a/rr_frontend/translation/src/lib.rs
+++ b/rr_frontend/translation/src/lib.rs
@@ -721,13 +721,12 @@ impl<'tcx, 'rcx> VerificationCtxt<'tcx, 'rcx> {
         info!("outputting generated code to {}", generated_dir_path.to_str().unwrap());
         if fs::read_dir(generated_dir_path).is_err() {
             warn!("Output directory {:?} does not exist, creating directory", generated_dir_path);
-            fs::create_dir_all(generated_dir_path).unwrap();
         } else {
             // purge contents
             info!("Removing the contents of the generated directory");
             fs::remove_dir_all(generated_dir_path).unwrap();
-            fs::create_dir(generated_dir_path).unwrap();
         }
+        fs::create_dir_all(generated_dir_path).unwrap();
 
         let code_path = generated_dir_path.join(format!("generated_code_{}.v", stem));
         let spec_path = generated_dir_path.join(format!("generated_specs_{}.v", stem));
-- 
GitLab