Skip to content

Commit e74c4dd

Browse files
committed
clippy auto fixes
1 parent 117b9cf commit e74c4dd

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

codegen/rust/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ pub fn emit(
101101
// On failure write generated code to a tempfile
102102
println!("Code generation produced unparsable code");
103103
write_to_tempfile(&tokens)?;
104-
return Err(io::Error::new(
105-
io::ErrorKind::Other,
104+
return Err(io::Error::other(
106105
format!("Failed to parse generated code: {:?}", e),
107106
));
108107
}
@@ -299,7 +298,7 @@ fn type_size(ty: &Type, ast: &AST) -> usize {
299298
fn type_size_bytes(ty: &Type, ast: &AST) -> usize {
300299
let s = type_size(ty, ast);
301300
let mut b = s >> 3;
302-
if s % 8 != 0 {
301+
if !s.is_multiple_of(8) {
303302
b += 1
304303
}
305304
b

lang/p4rs/src/checksum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn udp6_checksum(data: &[u8]) -> u16 {
6262
csum.add(payload_len[0], payload_len[1]);
6363

6464
let len = payload.len();
65-
let (odd, len) = if len % 2 == 0 {
65+
let (odd, len) = if len.is_multiple_of(2) {
6666
(false, len)
6767
} else {
6868
(true, len - 1)

lang/p4rs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ pub fn extract_bit_action_parameter(
370370
size: usize,
371371
) -> BitVec<u8, Msb0> {
372372
let mut byte_size = size >> 3;
373-
if size % 8 != 0 {
373+
if !size.is_multiple_of(8) {
374374
byte_size += 1;
375375
}
376376
let mut b: BitVec<u8, Msb0> =

lang/p4rs/src/table.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,14 @@ impl Key {
8484
}
8585

8686
#[derive(Debug, Clone, PartialEq, Hash, Eq, Serialize, Deserialize)]
87+
#[derive(Default)]
8788
pub enum Ternary {
89+
#[default]
8890
DontCare,
8991
Value(BigUintKey),
9092
Masked(BigUint, BigUint, usize),
9193
}
9294

93-
impl Default for Ternary {
94-
fn default() -> Self {
95-
Self::DontCare
96-
}
97-
}
9895

9996
#[derive(Debug, Clone, PartialEq, Hash, Eq, Serialize, Deserialize)]
10097
pub struct Prefix {

0 commit comments

Comments
 (0)