From 8f2430a31ff05fa1798ef6ceecdcb4fdf883da38 Mon Sep 17 00:00:00 2001
From: Vincent Lafeychine <vincent.lafeychine@proton.me>
Date: Sun, 14 Apr 2024 19:25:46 +0200
Subject: [PATCH] clippy: Fix needless_lifetimes

---
 rr_frontend/.cargo/config.toml                   |  1 -
 rr_frontend/radium/src/code.rs                   |  2 +-
 rr_frontend/radium/src/specs.rs                  |  2 +-
 .../src/bin/refinedrust-rustc.rs                 |  4 ++--
 rr_frontend/translation/src/environment/loops.rs |  4 ++--
 rr_frontend/translation/src/lib.rs               | 14 +++++++-------
 rr_frontend/translation/src/type_translator.rs   | 10 +++++-----
 rr_frontend/translation/src/utils.rs             | 16 ++++++++--------
 8 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml
index abbc7ce6..e77f7e0a 100644
--- a/rr_frontend/.cargo/config.toml
+++ b/rr_frontend/.cargo/config.toml
@@ -21,7 +21,6 @@ rustflags = [
     "-Aunused_variables",
 
     # clippy::complexity
-    "-Aclippy::needless_lifetimes",
     "-Aclippy::only_used_in_recursion",
     "-Aclippy::unnecessary_unwrap",
     "-Aclippy::useless_conversion",
diff --git a/rr_frontend/radium/src/code.rs b/rr_frontend/radium/src/code.rs
index e18d2411..3cc44e96 100644
--- a/rr_frontend/radium/src/code.rs
+++ b/rr_frontend/radium/src/code.rs
@@ -110,7 +110,7 @@ impl Display for RustType {
 }
 
 impl RustType {
-    pub fn of_type<'def>(ty: &Type<'def>, env: &[Option<LiteralTyParam>]) -> Self {
+    pub fn of_type(ty: &Type<'_>, env: &[Option<LiteralTyParam>]) -> Self {
         info!("Translating rustType: {:?}", ty);
         match ty {
             Type::Var(var) => {
diff --git a/rr_frontend/radium/src/specs.rs b/rr_frontend/radium/src/specs.rs
index fb0155f4..4323deb1 100644
--- a/rr_frontend/radium/src/specs.rs
+++ b/rr_frontend/radium/src/specs.rs
@@ -1222,7 +1222,7 @@ impl Display for UnionRepr {
 }
 
 /// Lookup a Rust-level type parameter identifier `name` in the given type parameter environment.
-pub fn lookup_ty_param<'a, 'b>(name: &'a str, env: &'b [LiteralTyParam]) -> Option<&'b LiteralTyParam> {
+pub fn lookup_ty_param<'a>(name: &'_ str, env: &'a [LiteralTyParam]) -> Option<&'a LiteralTyParam> {
     env.iter().find(|&names| names.rust_name == name)
 }
 
diff --git a/rr_frontend/refinedrust_frontend/src/bin/refinedrust-rustc.rs b/rr_frontend/refinedrust_frontend/src/bin/refinedrust-rustc.rs
index 8ea368fc..942b4d55 100644
--- a/rr_frontend/refinedrust_frontend/src/bin/refinedrust-rustc.rs
+++ b/rr_frontend/refinedrust_frontend/src/bin/refinedrust-rustc.rs
@@ -44,7 +44,7 @@ fn get_rr_version_info() -> String {
 struct RRCompilerCalls {}
 
 // From Prusti.
-fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> mir_borrowck::ProvidedValue<'tcx> {
+fn mir_borrowck(tcx: TyCtxt<'_>, def_id: LocalDefId) -> mir_borrowck::ProvidedValue<'_> {
     let body_with_facts = rustc_borrowck::consumers::get_body_with_borrowck_facts(
         tcx,
         def_id,
@@ -70,7 +70,7 @@ fn override_queries(_session: &Session, local: &mut Providers, _: &mut ExternPro
 
 /// Main entry point to the frontend that is called by the driver.
 /// This translates a crate.
-pub fn analyze<'tcx>(tcx: TyCtxt<'tcx>) {
+pub fn analyze(tcx: TyCtxt<'_>) {
     match translation::generate_coq_code(tcx, |vcx| vcx.write_coq_files()) {
         Ok(_) => (),
         Err(e) => {
diff --git a/rr_frontend/translation/src/environment/loops.rs b/rr_frontend/translation/src/environment/loops.rs
index 6cf20109..a840380c 100644
--- a/rr_frontend/translation/src/environment/loops.rs
+++ b/rr_frontend/translation/src/environment/loops.rs
@@ -123,8 +123,8 @@ impl<'b, 'tcx> Visitor<'tcx> for AccessCollector<'b, 'tcx> {
 }
 
 /// Returns the list of basic blocks ordered in the topological order (ignoring back edges).
-fn order_basic_blocks<'tcx>(
-    mir: &mir::Body<'tcx>,
+fn order_basic_blocks(
+    mir: &mir::Body<'_>,
     real_edges: &RealEdges,
     back_edges: &HashSet<(BasicBlockIndex, BasicBlockIndex)>,
     loop_depth: &dyn Fn(BasicBlockIndex) -> usize,
diff --git a/rr_frontend/translation/src/lib.rs b/rr_frontend/translation/src/lib.rs
index e0a33222..9dd7fa61 100644
--- a/rr_frontend/translation/src/lib.rs
+++ b/rr_frontend/translation/src/lib.rs
@@ -788,7 +788,7 @@ impl<'tcx, 'rcx> VerificationCtxt<'tcx, 'rcx> {
 }
 
 /// Register shims in the procedure registry.
-fn register_shims<'rcx, 'tcx>(vcx: &mut VerificationCtxt<'tcx, 'rcx>) -> Result<(), String> {
+fn register_shims(vcx: &mut VerificationCtxt<'_, '_>) -> Result<(), String> {
     for shim in vcx.shim_registry.get_function_shims().iter() {
         let did;
         if shim.is_method {
@@ -886,8 +886,8 @@ fn register_shims<'rcx, 'tcx>(vcx: &mut VerificationCtxt<'tcx, 'rcx>) -> Result<
     Ok(())
 }
 
-fn get_most_restrictive_function_mode<'tcx, 'rcx>(
-    vcx: &VerificationCtxt<'tcx, 'rcx>,
+fn get_most_restrictive_function_mode(
+    vcx: &VerificationCtxt<'_, '_>,
     did: DefId,
 ) -> function_body::ProcedureMode {
     let mut mode = function_body::ProcedureMode::Prove;
@@ -912,7 +912,7 @@ fn get_most_restrictive_function_mode<'tcx, 'rcx>(
 }
 
 /// Register functions of the crate in the procedure registry.
-fn register_functions<'rcx, 'tcx>(vcx: &mut VerificationCtxt<'tcx, 'rcx>) -> Result<(), String> {
+fn register_functions(vcx: &mut VerificationCtxt<'_, '_>) -> Result<(), String> {
     for &f in vcx.functions {
         let mut mode = get_most_restrictive_function_mode(vcx, f.to_def_id());
 
@@ -1089,7 +1089,7 @@ fn exit_with_error(s: &str) {
 
 /// Get all functions and closures in the current crate that have attributes on them and are not
 /// skipped due to rr::skip attributes.
-pub fn get_filtered_functions<'tcx>(env: &Environment<'tcx>) -> Vec<LocalDefId> {
+pub fn get_filtered_functions(env: &Environment<'_>) -> Vec<LocalDefId> {
     let mut functions = env.get_procedures();
     let closures = env.get_closures();
     info!("Found {} function(s) and {} closure(s)", functions.len(), closures.len());
@@ -1162,8 +1162,8 @@ pub fn register_consts<'rcx, 'tcx>(vcx: &mut VerificationCtxt<'tcx, 'rcx>) -> Re
 }
 
 /// Get and parse all module attributes.
-pub fn get_module_attributes<'tcx>(
-    env: &Environment<'tcx>,
+pub fn get_module_attributes(
+    env: &Environment<'_>,
 ) -> Result<HashMap<LocalDefId, mod_parser::ModuleAttrs>, String> {
     let modules = env.get_modules();
     let mut attrs = HashMap::new();
diff --git a/rr_frontend/translation/src/type_translator.rs b/rr_frontend/translation/src/type_translator.rs
index f18f97d7..bff1a1c6 100644
--- a/rr_frontend/translation/src/type_translator.rs
+++ b/rr_frontend/translation/src/type_translator.rs
@@ -47,7 +47,7 @@ pub(crate) struct AdtUseKey {
 }
 
 impl AdtUseKey {
-    pub fn new<'def>(defid: DefId, params: &[radium::Type<'def>]) -> Self {
+    pub fn new(defid: DefId, params: &[radium::Type<'_>]) -> Self {
         let generic_syntys: Vec<_> = params.iter().map(|ty| ty.get_syn_type()).collect();
         Self {
             base_did: defid,
@@ -95,9 +95,9 @@ impl<'def> TypeTranslationScope<'def> {
     }
 
     /// Create a new scope for a function translation with the given generic parameters.
-    pub fn new<'tcx>(
+    pub fn new(
         did: DefId,
-        ty_params: ty::GenericArgsRef<'tcx>,
+        ty_params: ty::GenericArgsRef<'_>,
         univ_lfts: HashMap<ty::RegionVid, String>,
     ) -> Result<Self, TranslationError> {
         info!("Entering procedure with ty_params {:?} and univ_lfts {:?}", ty_params, univ_lfts);
@@ -1930,9 +1930,9 @@ where
 }
 
 /// Format the Coq representation of an atomic region.
-pub fn format_atomic_region_direct<'def>(
+pub fn format_atomic_region_direct(
     r: &info::AtomicRegion,
-    scope: Option<&TypeTranslationScope<'def>>,
+    scope: Option<&TypeTranslationScope<'_>>,
 ) -> String {
     match r {
         info::AtomicRegion::Loan(_, r) => {
diff --git a/rr_frontend/translation/src/utils.rs b/rr_frontend/translation/src/utils.rs
index ce181fb1..32f57348 100644
--- a/rr_frontend/translation/src/utils.rs
+++ b/rr_frontend/translation/src/utils.rs
@@ -148,7 +148,7 @@ pub fn convert_ty_to_flat_type<'tcx>(env: &Environment<'tcx>, ty: ty::Ty<'tcx>)
     }
 }
 
-pub fn get_cleaned_def_path<'tcx>(tcx: TyCtxt<'tcx>, did: DefId) -> Vec<String> {
+pub fn get_cleaned_def_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<String> {
     let def_path = tcx.def_path_str(did);
     // we clean this up a bit and segment it
     let mut components = Vec::new();
@@ -210,7 +210,7 @@ pub fn get_export_path_for_did(env: &Environment, did: DefId) -> Vec<String> {
 
 /// Gets an instance for a path.
 /// Taken from Miri https://github.com/rust-lang/miri/blob/31fb32e49f42df19b45baccb6aa80c3d726ed6d5/src/helpers.rs#L48.
-pub fn try_resolve_did_direct<'tcx, T>(tcx: TyCtxt<'tcx>, path: &[T]) -> Option<DefId>
+pub fn try_resolve_did_direct<T>(tcx: TyCtxt<'_>, path: &[T]) -> Option<DefId>
 where
     T: AsRef<str>,
 {
@@ -223,7 +223,7 @@ where
                 index: CRATE_DEF_INDEX,
             };
 
-            let mut items: &'tcx [rustc_middle::metadata::ModChild] = tcx.module_children(krate);
+            let mut items: &[rustc_middle::metadata::ModChild] = tcx.module_children(krate);
             let mut path_it = path.iter().skip(1).peekable();
 
             while let Some(segment) = path_it.next() {
@@ -243,7 +243,7 @@ where
         })
 }
 
-pub fn try_resolve_did<'tcx, T>(tcx: TyCtxt<'tcx>, path: &[T]) -> Option<DefId>
+pub fn try_resolve_did<T>(tcx: TyCtxt<'_>, path: &[T]) -> Option<DefId>
 where
     T: AsRef<str>,
 {
@@ -377,7 +377,7 @@ pub fn try_resolve_trait_method_did<'tcx>(
 /// Try to get a defid of a method at the given path.
 /// This does not handle trait methods.
 /// This also does not handle overlapping method definitions/specialization well.
-pub fn try_resolve_method_did_direct<'tcx, T>(tcx: TyCtxt<'tcx>, path: &[T]) -> Option<DefId>
+pub fn try_resolve_method_did_direct<T>(tcx: TyCtxt<'_>, path: &[T]) -> Option<DefId>
 where
     T: AsRef<str>,
 {
@@ -390,7 +390,7 @@ where
                 index: CRATE_DEF_INDEX,
             };
 
-            let mut items: &'tcx [rustc_middle::metadata::ModChild] = tcx.module_children(krate);
+            let mut items: &[rustc_middle::metadata::ModChild] = tcx.module_children(krate);
             let mut path_it = path.iter().skip(1).peekable();
 
             while let Some(segment) = path_it.next() {
@@ -406,7 +406,7 @@ where
                         // just the method remaining
                         if path_it.len() == 1 {
                             let did: DefId = item.res.def_id();
-                            let impls: &'tcx [DefId] = tcx.inherent_impls(did);
+                            let impls: &[DefId] = tcx.inherent_impls(did);
                             info!("trying to find method among impls {:?}", impls);
 
                             let find = path_it.next().unwrap();
@@ -437,7 +437,7 @@ where
         })
 }
 
-pub fn try_resolve_method_did<'tcx, T>(tcx: TyCtxt<'tcx>, path: &[T]) -> Option<DefId>
+pub fn try_resolve_method_did<T>(tcx: TyCtxt<'_>, path: &[T]) -> Option<DefId>
 where
     T: AsRef<str>,
 {
-- 
GitLab