[前][次][番号順一覧][スレッド一覧]

ruby-changes:73807

From: Jimmy <ko1@a...>
Date: Sat, 1 Oct 2022 00:15:22 +0900 (JST)
Subject: [ruby-changes:73807] 31461c7e0e (master): A bunch of clippy auto fixes for yjit (#6476)

https://git.ruby-lang.org/ruby.git/commit/?id=31461c7e0e

From 31461c7e0eab4963ccc8649ea8ebf27979132c0c Mon Sep 17 00:00:00 2001
From: Jimmy Miller <jimmy.miller@s...>
Date: Fri, 30 Sep 2022 10:14:55 -0500
Subject: A bunch of clippy auto fixes for yjit (#6476)

---
 yjit/src/asm/arm64/arg/shifted_imm.rs   |  2 +-
 yjit/src/asm/arm64/arg/truncate.rs      |  8 +++----
 yjit/src/asm/arm64/inst/branch_cond.rs  |  3 ++-
 yjit/src/asm/arm64/inst/halfword_imm.rs |  2 +-
 yjit/src/asm/arm64/inst/nop.rs          |  2 +-
 yjit/src/asm/arm64/inst/pc_rel.rs       |  2 +-
 yjit/src/asm/arm64/mod.rs               |  8 +++----
 yjit/src/asm/arm64/opnd.rs              |  2 +-
 yjit/src/asm/mod.rs                     | 10 ++++----
 yjit/src/backend/ir.rs                  |  6 ++---
 yjit/src/backend/tests.rs               |  4 ++--
 yjit/src/codegen.rs                     | 42 ++++++++++++++++-----------------
 yjit/src/cruby.rs                       |  2 +-
 yjit/src/disasm.rs                      |  6 ++---
 yjit/src/invariants.rs                  |  2 +-
 yjit/src/stats.rs                       |  4 ++--
 16 files changed, 53 insertions(+), 52 deletions(-)

diff --git a/yjit/src/asm/arm64/arg/shifted_imm.rs b/yjit/src/asm/arm64/arg/shifted_imm.rs
index 5d1eeaf26d..0dd7af25b5 100644
--- a/yjit/src/asm/arm64/arg/shifted_imm.rs
+++ b/yjit/src/asm/arm64/arg/shifted_imm.rs
@@ -18,7 +18,7 @@ impl TryFrom<u64> for ShiftedImmediate { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/arg/shifted_imm.rs#L18
 
     /// Attempt to convert a u64 into a BitmaskImm.
     fn try_from(value: u64) -> Result<Self, Self::Error> {
-        let mut current = value;
+        let current = value;
         if current < 2_u64.pow(12) {
             return Ok(ShiftedImmediate { shift: Shift::LSL0, value: current as u16 });
         }
diff --git a/yjit/src/asm/arm64/arg/truncate.rs b/yjit/src/asm/arm64/arg/truncate.rs
index 52f2c012cb..0de562f808 100644
--- a/yjit/src/asm/arm64/arg/truncate.rs
+++ b/yjit/src/asm/arm64/arg/truncate.rs
@@ -31,7 +31,7 @@ pub fn truncate_imm<T: Into<i32>, const WIDTH: usize>(imm: T) -> u32 { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/arg/truncate.rs#L31
 /// This should effectively be a no-op since we're just dropping leading zeroes.
 pub fn truncate_uimm<T: Into<u32>, const WIDTH: usize>(uimm: T) -> u32 {
     let value: u32 = uimm.into();
-    let masked = (value & ((1 << WIDTH) - 1));
+    let masked = value & ((1 << WIDTH) - 1);
 
     // Assert that we didn't drop any bits by truncating.
     assert_eq!(value, masked);
@@ -46,21 +46,21 @@ mod tests { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/arg/truncate.rs#L46
     #[test]
     fn test_truncate_imm_positive() {
         let inst = truncate_imm::<i32, 4>(5);
-        let result: u32 = inst.into();
+        let result: u32 = inst;
         assert_eq!(0b0101, result);
     }
 
     #[test]
     fn test_truncate_imm_negative() {
         let inst = truncate_imm::<i32, 4>(-5);
-        let result: u32 = inst.into();
+        let result: u32 = inst;
         assert_eq!(0b1011, result);
     }
 
     #[test]
     fn test_truncate_uimm() {
         let inst = truncate_uimm::<u32, 4>(5);
-        let result: u32 = inst.into();
+        let result: u32 = inst;
         assert_eq!(0b0101, result);
     }
 }
diff --git a/yjit/src/asm/arm64/inst/branch_cond.rs b/yjit/src/asm/arm64/inst/branch_cond.rs
index 4338cf0f4f..fcc07f69aa 100644
--- a/yjit/src/asm/arm64/inst/branch_cond.rs
+++ b/yjit/src/asm/arm64/inst/branch_cond.rs
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/inst/branch_cond.rs#L1
-use super::super::arg::{Condition, InstructionOffset, truncate_imm};
+use super::super::arg::{InstructionOffset, truncate_imm};
 
 /// The struct that represents an A64 conditional branch instruction that can be
 /// encoded.
@@ -50,6 +50,7 @@ impl From<BranchCond> for [u8; 4] { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/inst/branch_cond.rs#L50
 #[cfg(test)]
 mod tests {
     use super::*;
+    use super::super::super::arg::Condition;
 
     #[test]
     fn test_b_eq() {
diff --git a/yjit/src/asm/arm64/inst/halfword_imm.rs b/yjit/src/asm/arm64/inst/halfword_imm.rs
index c31d1f8945..0ddae8e8de 100644
--- a/yjit/src/asm/arm64/inst/halfword_imm.rs
+++ b/yjit/src/asm/arm64/inst/halfword_imm.rs
@@ -95,7 +95,7 @@ const FAMILY: u32 = 0b111100; https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/inst/halfword_imm.rs#L95
 impl From<HalfwordImm> for u32 {
     /// Convert an instruction into a 32-bit value.
     fn from(inst: HalfwordImm) -> Self {
-        let (mut opc, imm) = match inst.index {
+        let (opc, imm) = match inst.index {
             Index::None => {
                 assert_eq!(inst.imm & 1, 0, "immediate offset must be even");
                 let imm12 = truncate_imm::<_, 12>(inst.imm / 2);
diff --git a/yjit/src/asm/arm64/inst/nop.rs b/yjit/src/asm/arm64/inst/nop.rs
index a99f8d34b7..d58b3574a9 100644
--- a/yjit/src/asm/arm64/inst/nop.rs
+++ b/yjit/src/asm/arm64/inst/nop.rs
@@ -18,7 +18,7 @@ impl Nop { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/inst/nop.rs#L18
 
 impl From<Nop> for u32 {
     /// Convert an instruction into a 32-bit value.
-    fn from(inst: Nop) -> Self {
+    fn from(_inst: Nop) -> Self {
         0b11010101000000110010000000011111
     }
 }
diff --git a/yjit/src/asm/arm64/inst/pc_rel.rs b/yjit/src/asm/arm64/inst/pc_rel.rs
index fa330cb9d6..bd1a2b9367 100644
--- a/yjit/src/asm/arm64/inst/pc_rel.rs
+++ b/yjit/src/asm/arm64/inst/pc_rel.rs
@@ -53,7 +53,7 @@ impl From<PCRelative> for u32 { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/inst/pc_rel.rs#L53
 
         // Toggle the sign bit if necessary.
         if inst.imm < 0 {
-            immhi |= (1 << 18);
+            immhi |= 1 << 18;
         }
 
         0
diff --git a/yjit/src/asm/arm64/mod.rs b/yjit/src/asm/arm64/mod.rs
index 88431ce30a..9d85705ff8 100644
--- a/yjit/src/asm/arm64/mod.rs
+++ b/yjit/src/asm/arm64/mod.rs
@@ -15,7 +15,7 @@ pub use opnd::*; https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/mod.rs#L15
 
 /// Checks that a signed value fits within the specified number of bits.
 pub const fn imm_fits_bits(imm: i64, num_bits: u8) -> bool {
-    let minimum = if num_bits == 64 { i64::MIN } else { -2_i64.pow((num_bits as u32) - 1) };
+    let minimum = if num_bits == 64 { i64::MIN } else { -(2_i64.pow((num_bits as u32) - 1)) };
     let maximum = if num_bits == 64 { i64::MAX } else { 2_i64.pow((num_bits as u32) - 1) - 1 };
 
     imm >= minimum && imm <= maximum
@@ -1025,8 +1025,8 @@ mod tests { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/mod.rs#L1025
         assert!(imm_fits_bits(i32::MAX.into(), 32));
         assert!(imm_fits_bits(i32::MIN.into(), 32));
 
-        assert!(imm_fits_bits(i64::MAX.into(), 64));
-        assert!(imm_fits_bits(i64::MIN.into(), 64));
+        assert!(imm_fits_bits(i64::MAX, 64));
+        assert!(imm_fits_bits(i64::MIN, 64));
     }
 
     #[test]
@@ -1034,7 +1034,7 @@ mod tests { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/mod.rs#L1034
         assert!(uimm_fits_bits(u8::MAX.into(), 8));
         assert!(uimm_fits_bits(u16::MAX.into(), 16));
         assert!(uimm_fits_bits(u32::MAX.into(), 32));
-        assert!(uimm_fits_bits(u64::MAX.into(), 64));
+        assert!(uimm_fits_bits(u64::MAX, 64));
     }
 
     #[test]
diff --git a/yjit/src/asm/arm64/opnd.rs b/yjit/src/asm/arm64/opnd.rs
index 0dc614ab4e..108824e08d 100644
--- a/yjit/src/asm/arm64/opnd.rs
+++ b/yjit/src/asm/arm64/opnd.rs
@@ -1,4 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/arm64/opnd.rs#L1
-use crate::asm::{imm_num_bits, uimm_num_bits};
+
 
 /// This operand represents a register.
 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs
index f5501a4bc7..2bc83ec059 100644
--- a/yjit/src/asm/mod.rs
+++ b/yjit/src/asm/mod.rs
@@ -220,7 +220,7 @@ impl CodeBlock { https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/mod.rs#L220
 
     /// Allocate a new label with a given name
     pub fn new_label(&mut self, name: String) -> usize {
-        assert!(!name.contains(" "), "use underscores in label names, not spaces");
+        assert!(!name.contains(' '), "use underscores in label names, not spaces");
 
         // This label doesn't have an address yet
         self.label_addrs.push(0);
@@ -378,8 +378,8 @@ mod tests https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/mod.rs#L378
         assert_eq!(imm_num_bits(i32::MIN.into()), 32);
         assert_eq!(imm_num_bits(i32::MAX.into()), 32);
 
-        assert_eq!(imm_num_bits(i64::MIN.into()), 64);
-        assert_eq!(imm_num_bits(i64::MAX.into()), 64);
+        assert_eq!(imm_num_bits(i64::MIN), 64);
+        assert_eq!(imm_num_bits(i64::MAX), 64);
     }
 
     #[test]
@@ -393,7 +393,7 @@ mod tests https://github.com/ruby/ruby/blob/trunk/yjit/src/asm/mod.rs#L393
         assert_eq!(uimm_num_bits(((u16::MAX as u32) + 1).into()), 32);
         assert_eq!(uimm_num_bits(u32::MAX.into()), 32);
 
-        assert_eq!(uimm_num_bits(((u32::MAX as u64) + 1).into()), 64);
-        assert_eq!(uimm_num_bits(u64::MAX.into()), 64);
+        assert_eq!(uimm_num_bits(((u32::MAX as u64) + 1)), 64);
+        assert_eq!(uimm_num_bits(u64::MAX), 64);
     }
 }
diff --git a/yjit/src/backend/ir.rs b/yjit/src/backend/ir.rs
index 609ca8eaf4..dfdc1deb0d 100644
--- a/yjit/src/backend/ir.rs
+++ b/yjit/src/backend/ir.rs
@@ -912,7 +912,7 @@ impl Assembler https://github.com/ruby/ruby/blob/trunk/yjit/src/backend/ir.rs#L912
     /// Create a new label instance that we can jump to
     pub fn new_label(&mut self, name: &str) -> Target
     {
-        assert!(!name.contains(" "), "use underscores in label names, not spaces");
+        assert!(!name.contains(' '), "use underscores in label names, not spaces");
 
         let label_idx = self.label_names.len();
         self.label_names.push(name.to_string());
@@ -1232,10 + (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]