From c13062ca03f4a55f6ad3a7f828ac78504c62ea40 Mon Sep 17 00:00:00 2001
From: Vincent Lafeychine <vincent.lafeychine@proton.me>
Date: Mon, 29 Apr 2024 23:24:46 +0200
Subject: [PATCH] clippy: Fix cast_lossless

---
 rr_frontend/.cargo/config.toml                 | 1 -
 rr_frontend/attribute_parse/src/parse.rs       | 4 +++-
 rr_frontend/translation/src/type_translator.rs | 2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/rr_frontend/.cargo/config.toml b/rr_frontend/.cargo/config.toml
index 8afe9850..536dee23 100644
--- a/rr_frontend/.cargo/config.toml
+++ b/rr_frontend/.cargo/config.toml
@@ -32,7 +32,6 @@ rustflags = [
     "-Aclippy::string_lit_as_bytes",
 
     # clippy::pedantic
-    "-Aclippy::cast_lossless",
     "-Aclippy::cloned_instead_of_copied",
     "-Aclippy::default_trait_access",
     "-Aclippy::doc_markdown",
diff --git a/rr_frontend/attribute_parse/src/parse.rs b/rr_frontend/attribute_parse/src/parse.rs
index b46b6a69..00c5fa95 100644
--- a/rr_frontend/attribute_parse/src/parse.rs
+++ b/rr_frontend/attribute_parse/src/parse.rs
@@ -662,7 +662,9 @@ impl BigInt {
 
     fn reserve_two_digits(&mut self) {
         let len = self.digits.len();
-        let desired = len + !self.digits.ends_with(&[0, 0]) as usize + !self.digits.ends_with(&[0]) as usize;
+        let desired =
+            len + usize::from(!self.digits.ends_with(&[0, 0])) + usize::from(!self.digits.ends_with(&[0]));
+
         self.digits.resize(desired, 0);
     }
 }
diff --git a/rr_frontend/translation/src/type_translator.rs b/rr_frontend/translation/src/type_translator.rs
index 4eea6b38..01bd9c67 100644
--- a/rr_frontend/translation/src/type_translator.rs
+++ b/rr_frontend/translation/src/type_translator.rs
@@ -950,7 +950,7 @@ impl<'def, 'tcx: 'def> TypeTranslator<'def, 'tcx> {
                     map.insert(name, evaluated_int);
                 },
                 ty::VariantDiscr::Relative(offset) => {
-                    let idx: i128 = last_explicit_discr + (offset as i128);
+                    let idx: i128 = last_explicit_discr + i128::from(offset);
                     map.insert(name, idx);
                 },
             }
-- 
GitLab