Skip to content

Commit 5884c21

Browse files
andreeafloresculauralt
authored andcommitted
fix clippy warnings from switching to Rust 1.52.1
From is now prefered over Into because because implementing From provides the Into implementation as well by default. Explicitly define the type of constants when initializing them instead of using `as` to convert them to the desired type. Signed-off-by: Andreea Florescu <[email protected]>
1 parent 69f4e39 commit 5884c21

File tree

3 files changed

+7
-16
lines changed

3 files changed

+7
-16
lines changed

src/endian.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ macro_rules! endian_type {
7777
}
7878
}
7979

80-
impl Into<$old_type> for $new_type {
81-
fn into(self) -> $old_type {
82-
$old_type::$from_new(self.0)
80+
impl From<$new_type> for $old_type {
81+
fn from(v: $new_type) -> $old_type {
82+
v.to_native()
8383
}
8484
}
8585

src/guest_memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ mod tests {
10701070
let offset = GuestAddress(0x30);
10711071
let count: usize = 0x20;
10721072
assert_eq!(
1073-
0x20 as usize,
1073+
0x20_usize,
10741074
mem.read_from(offset, &mut Cursor::new(&image), count)
10751075
.unwrap()
10761076
);

src/mmap.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,7 @@ mod tests {
812812

813813
#[test]
814814
fn test_overlapping_memory_regions() {
815-
let regions_summary = [
816-
(GuestAddress(0), 100 as usize),
817-
(GuestAddress(99), 100 as usize),
818-
];
815+
let regions_summary = [(GuestAddress(0), 100_usize), (GuestAddress(99), 100_usize)];
819816

820817
assert_eq!(
821818
format!(
@@ -858,10 +855,7 @@ mod tests {
858855

859856
#[test]
860857
fn test_unsorted_memory_regions() {
861-
let regions_summary = [
862-
(GuestAddress(100), 100 as usize),
863-
(GuestAddress(0), 100 as usize),
864-
];
858+
let regions_summary = [(GuestAddress(100), 100_usize), (GuestAddress(0), 100_usize)];
865859

866860
assert_eq!(
867861
format!(
@@ -904,10 +898,7 @@ mod tests {
904898

905899
#[test]
906900
fn test_valid_memory_regions() {
907-
let regions_summary = [
908-
(GuestAddress(0), 100 as usize),
909-
(GuestAddress(100), 100 as usize),
910-
];
901+
let regions_summary = [(GuestAddress(0), 100_usize), (GuestAddress(100), 100_usize)];
911902

912903
let guest_mem = GuestMemoryMmap::new();
913904
assert_eq!(guest_mem.regions.len(), 0);

0 commit comments

Comments
 (0)