Replace as casts with type-conversion functions.
https://github.com/rust-lang-nursery/rust-clippy/wiki#cast_lossless
This commit is contained in:
@@ -105,7 +105,7 @@ impl BranchRange {
|
||||
///
|
||||
/// This method does not detect if the range is larger than 2 GB.
|
||||
pub fn contains(self, branch: CodeOffset, dest: CodeOffset) -> bool {
|
||||
let d = dest.wrapping_sub(branch + self.origin as CodeOffset) as i32;
|
||||
let d = dest.wrapping_sub(branch + CodeOffset::from(self.origin)) as i32;
|
||||
let s = 32 - self.bits;
|
||||
d == d << s >> s
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ impl EncInfo {
|
||||
pub fn bytes(&self, enc: Encoding) -> CodeOffset {
|
||||
self.sizing
|
||||
.get(enc.recipe())
|
||||
.map(|s| s.bytes as CodeOffset)
|
||||
.map(|s| CodeOffset::from(s.bytes))
|
||||
.unwrap_or(0)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ struct Args {
|
||||
impl Args {
|
||||
fn new(bits: u16, gpr: &'static [RU], fpr_limit: usize) -> Args {
|
||||
Args {
|
||||
pointer_bytes: bits as u32 / 8,
|
||||
pointer_bytes: u32::from(bits) / 8,
|
||||
pointer_bits: bits,
|
||||
pointer_type: ir::Type::int(bits).unwrap(),
|
||||
gpr,
|
||||
|
||||
@@ -174,7 +174,7 @@ impl RegClassData {
|
||||
|
||||
/// Get a specific register unit in this class.
|
||||
pub fn unit(&self, offset: usize) -> RegUnit {
|
||||
let uoffset = offset * self.width as usize;
|
||||
let uoffset = offset * usize::from(self.width);
|
||||
self.first + uoffset as RegUnit
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ impl EntityRef for RegClassIndex {
|
||||
}
|
||||
|
||||
fn index(self) -> usize {
|
||||
self.0 as usize
|
||||
usize::from(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ impl Args {
|
||||
fn new(bits: u16, enable_e: bool) -> Args {
|
||||
Args {
|
||||
pointer_bits: bits,
|
||||
pointer_bytes: bits as u32 / 8,
|
||||
pointer_bytes: u32::from(bits) / 8,
|
||||
pointer_type: Type::int(bits).unwrap(),
|
||||
regs: 0,
|
||||
reg_limit: if enable_e { 6 } else { 8 },
|
||||
|
||||
Reference in New Issue
Block a user