summaryrefslogtreecommitdiff
path: root/yjit/src/asm
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-04-27 14:08:52 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2022-04-29 15:03:45 -0400
commitfead7107abc494ef051fd26357c21a546b49c7d9 (patch)
tree8605fc5e827abb03f2020193ba3f28ca2108147c /yjit/src/asm
parentf8e4488e5e01c07cc8c139e6030a5dfca45b824c (diff)
YJIT: Adopt Clippy suggestions we like
This adopts most suggestions that rust-clippy is confident enough to auto apply. The manual changes mostly fix manual if-lets and take opportunities to use the `Default` trait on standard collections. Co-authored-by: Kevin Newton <kddnewton@gmail.com> Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5853
Diffstat (limited to 'yjit/src/asm')
-rw-r--r--yjit/src/asm/mod.rs2
-rw-r--r--yjit/src/asm/x86_64/mod.rs4
-rw-r--r--yjit/src/asm/x86_64/tests.rs2
3 files changed, 4 insertions, 4 deletions
diff --git a/yjit/src/asm/mod.rs b/yjit/src/asm/mod.rs
index ba0e8713d0..79a08a7381 100644
--- a/yjit/src/asm/mod.rs
+++ b/yjit/src/asm/mod.rs
@@ -225,7 +225,7 @@ impl CodeBlock {
// Get a direct pointer into the executable memory block
pub fn get_ptr(&self, offset: usize) -> CodePtr {
unsafe {
- let ptr = self.mem_block.offset(offset as isize);
+ let ptr = self.mem_block.add(offset);
CodePtr(ptr)
}
}
diff --git a/yjit/src/asm/x86_64/mod.rs b/yjit/src/asm/x86_64/mod.rs
index c748ec1154..902b3eb9cc 100644
--- a/yjit/src/asm/x86_64/mod.rs
+++ b/yjit/src/asm/x86_64/mod.rs
@@ -1295,12 +1295,12 @@ pub fn sub(cb: &mut CodeBlock, opnd0: X86Opnd, opnd1: X86Opnd) {
fn resize_opnd(opnd: X86Opnd, num_bits: u8) -> X86Opnd {
match opnd {
X86Opnd::Reg(reg) => {
- let mut cloned = reg.clone();
+ let mut cloned = reg;
cloned.num_bits = num_bits;
X86Opnd::Reg(cloned)
},
X86Opnd::Mem(mem) => {
- let mut cloned = mem.clone();
+ let mut cloned = mem;
cloned.num_bits = num_bits;
X86Opnd::Mem(cloned)
},
diff --git a/yjit/src/asm/x86_64/tests.rs b/yjit/src/asm/x86_64/tests.rs
index bb36468a34..f8c34fd3b7 100644
--- a/yjit/src/asm/x86_64/tests.rs
+++ b/yjit/src/asm/x86_64/tests.rs
@@ -222,7 +222,7 @@ fn test_mov_unsigned() {
// MOV RAX, imm64, will not move down into EAX since it does not fit into 32 bits
check_bytes("48b80000000001000000", |cb| mov(cb, RAX, uimm_opnd(u32::MAX as u64 + 1)));
- check_bytes("48b8ffffffffffffffff", |cb| mov(cb, RAX, uimm_opnd(u64::MAX.into())));
+ check_bytes("48b8ffffffffffffffff", |cb| mov(cb, RAX, uimm_opnd(u64::MAX)));
check_bytes("49b8ffffffffffffffff", |cb| mov(cb, R8, uimm_opnd(u64::MAX)));
// MOV r8, imm8