From 3dbd870fd6ea705200fecb381bec82c164fef774 Mon Sep 17 00:00:00 2001
From: Vincent Lafeychine <vincent.lafeychine@proton.me>
Date: Sun, 14 Apr 2024 17:39:10 +0200
Subject: [PATCH] clippy: Fix manual_flatten

---
 rr_frontend/.cargo/config.toml               |  1 -
 rr_frontend/translation/src/function_body.rs | 18 +++++---------
 rr_frontend/translation/src/lib.rs           | 26 +++++++++-----------
 3 files changed, 18 insertions(+), 27 deletions(-)

diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml
index 1c39b10e..122241c5 100644
--- a/rr_frontend/.cargo/config.toml
+++ b/rr_frontend/.cargo/config.toml
@@ -21,7 +21,6 @@ rustflags = [
     "-Aunused_variables",
 
     # clippy::complexity
-    "-Aclippy::manual_flatten",
     "-Aclippy::match_single_binding",
     "-Aclippy::needless_borrowed_reference",
     "-Aclippy::needless_lifetimes",
diff --git a/rr_frontend/translation/src/function_body.rs b/rr_frontend/translation/src/function_body.rs
index 3826e250..ebd311e3 100644
--- a/rr_frontend/translation/src/function_body.rs
+++ b/rr_frontend/translation/src/function_body.rs
@@ -538,10 +538,8 @@ impl<'a, 'def: 'a, 'tcx: 'def> FunctionTranslator<'a, 'def, 'tcx> {
                 )?;
                 // add generic args to the fn
                 let generics = &type_scope.generic_scope;
-                for t in generics.iter() {
-                    if let Some(ref t) = t {
-                        translated_fn.add_generic_type(t.clone());
-                    }
+                for t in generics.iter().flatten() {
+                    translated_fn.add_generic_type(t.clone());
                 }
 
                 let mut t = Self {
@@ -672,10 +670,8 @@ impl<'a, 'def: 'a, 'tcx: 'def> FunctionTranslator<'a, 'def, 'tcx> {
                 let type_scope = TypeTranslationScope::new(proc.get_id(), params, universal_lifetime_map)?;
                 // add generic args to the fn
                 let generics = &type_scope.generic_scope;
-                for t in generics.iter() {
-                    if let Some(t) = t {
-                        translated_fn.add_generic_type(t.clone());
-                    }
+                for t in generics.iter().flatten() {
+                    translated_fn.add_generic_type(t.clone());
                 }
 
                 let mut t = Self {
@@ -1201,10 +1197,8 @@ impl<'a, 'def: 'a, 'tcx: 'def> BodyTranslator<'a, 'def, 'tcx> {
         // assume that all generics are layoutable
         {
             let scope = self.ty_translator.scope.borrow();
-            for g in scope.generic_scope.iter() {
-                if let Some(ty) = g {
-                    self.translated_fn.assume_synty_layoutable(radium::SynType::Literal(ty.syn_type.clone()));
-                }
+            for ty in scope.generic_scope.iter().flatten() {
+                self.translated_fn.assume_synty_layoutable(radium::SynType::Literal(ty.syn_type.clone()));
             }
         }
         // assume that all used literals are layoutable
diff --git a/rr_frontend/translation/src/lib.rs b/rr_frontend/translation/src/lib.rs
index 2b8d7f24..e0a33222 100644
--- a/rr_frontend/translation/src/lib.rs
+++ b/rr_frontend/translation/src/lib.rs
@@ -742,20 +742,18 @@ impl<'tcx, 'rcx> VerificationCtxt<'tcx, 'rcx> {
                 }
             }
 
-            for file in read {
-                if let Ok(file) = file {
-                    // check if the file name is okay
-                    let filename = file.file_name();
-                    if let Some(filename) = filename.to_str() {
-                        if filename == "dune" {
-                            continue;
-                        } else if proof_files_to_generate.contains(filename) {
-                            continue;
-                        } else {
-                            println!(
-                                "Warning: Proof file {filename} does not have a matching Rust function to verify."
-                            );
-                        }
+            for file in read.flatten() {
+                // check if the file name is okay
+                let filename = file.file_name();
+                if let Some(filename) = filename.to_str() {
+                    if filename == "dune" {
+                        continue;
+                    } else if proof_files_to_generate.contains(filename) {
+                        continue;
+                    } else {
+                        println!(
+                            "Warning: Proof file {filename} does not have a matching Rust function to verify."
+                        );
                     }
                 }
             }
-- 
GitLab