misc: apply clippy lints

This commit is contained in:
2025-06-19 15:51:23 +01:00
parent c1d72e8d4c
commit 81433dcbcd
17 changed files with 134 additions and 127 deletions
+5 -4
View File
@@ -86,7 +86,8 @@ impl TryFrom<u8> for Register {
}
Ok(match idx {
// System registers are not indexable in the reg file so they cannot be modified by instructions.
// System registers are not indexable in the reg file so they cannot be
// modified by instructions.
0x0 => Self::Rg0,
0x1 => Self::Rg1,
0x2 => Self::Rg2,
@@ -414,8 +415,8 @@ impl std::fmt::Display for Instruction {
Self::Increment(a) | Self::Decrement(a) => write!(f, " {}", a.sr1),
Self::Interrupt(a) => write!(f, " {}", a.as_u8()),
Self::Data(a) => write!(f, " {}", a),
Self::Segment(x) => write!(f, " [SEGMENT {}]", x),
Self::Data(a) => write!(f, " {a}"),
Self::Segment(x) => write!(f, " [SEGMENT {x}]"),
_ => Ok(()),
}
}
@@ -469,7 +470,7 @@ impl TryFrom<u32> for Instruction {
0x24 => Ok(Self::Halt),
0x25 => Ok(Self::AddImmediate(ITypeArgs::try_from(data)?)),
0x26 => Ok(Self::SubImmediate(ITypeArgs::try_from(data)?)),
0x3F => Ok(Self::Segment(data as u8 as u32)),
0x3F => Ok(Self::Segment(u32::from(data as u8))),
_ => Err(InstructionDecodeError::InvalidOpcode(opcode)),
}
}
+3 -2
View File
@@ -16,7 +16,8 @@ fn encode_no_args(opcode: u8) -> u32 {
(opcode << 26) | (sr1 << 21) | (sr2 << 16) | (dr << 11) | (shamt << 6)
}
/// Expands to a match statement that calls encode on instructions that implement [`Encode`]:
/// Expands to a match statement that calls encode on instructions that implement
/// [`Encode`]:
///
/// # Usage
///
@@ -58,7 +59,7 @@ impl Encode for Instruction {
Self::Segment(segment) => {
let opcode = u32::from(self.opcode());
let segment = segment as u8;
(opcode << 26) | (segment as u32)
(opcode << 26) | u32::from(segment)
}
]
)