diff --git a/book/text/book.toml b/book/text/book.toml index a75b2341..4ef9c82f 100644 --- a/book/text/book.toml +++ b/book/text/book.toml @@ -1,7 +1,6 @@ [book] authors = ["Ryan Goodfellow"] language = "en" -multilingual = false src = "src" title = "The x4c Book" diff --git a/book/text/theme/index.hbs b/book/text/theme/index.hbs index e131c461..d5e538d3 100644 --- a/book/text/theme/index.hbs +++ b/book/text/theme/index.hbs @@ -196,17 +196,17 @@ @@ -214,17 +214,17 @@ diff --git a/codegen/rust/src/lib.rs b/codegen/rust/src/lib.rs index a41ba0e7..4d9ec523 100644 --- a/codegen/rust/src/lib.rs +++ b/codegen/rust/src/lib.rs @@ -101,10 +101,10 @@ pub fn emit( // On failure write generated code to a tempfile println!("Code generation produced unparsable code"); write_to_tempfile(&tokens)?; - return Err(io::Error::new( - io::ErrorKind::Other, - format!("Failed to parse generated code: {:?}", e), - )); + return Err(io::Error::other(format!( + "Failed to parse generated code: {:?}", + e + ))); } }; fs::write(filename, prettyplease::unparse(&f))?; @@ -299,7 +299,7 @@ fn type_size(ty: &Type, ast: &AST) -> usize { fn type_size_bytes(ty: &Type, ast: &AST) -> usize { let s = type_size(ty, ast); let mut b = s >> 3; - if s % 8 != 0 { + if !s.is_multiple_of(8) { b += 1 } b diff --git a/lang/p4rs/src/checksum.rs b/lang/p4rs/src/checksum.rs index 936289dd..7b8e9ad2 100644 --- a/lang/p4rs/src/checksum.rs +++ b/lang/p4rs/src/checksum.rs @@ -62,7 +62,7 @@ pub fn udp6_checksum(data: &[u8]) -> u16 { csum.add(payload_len[0], payload_len[1]); let len = payload.len(); - let (odd, len) = if len % 2 == 0 { + let (odd, len) = if len.is_multiple_of(2) { (false, len) } else { (true, len - 1) diff --git a/lang/p4rs/src/lib.rs b/lang/p4rs/src/lib.rs index d63c3c14..4d9d49c8 100644 --- a/lang/p4rs/src/lib.rs +++ b/lang/p4rs/src/lib.rs @@ -370,7 +370,7 @@ pub fn extract_bit_action_parameter( size: usize, ) -> BitVec { let mut byte_size = size >> 3; - if size % 8 != 0 { + if !size.is_multiple_of(8) { byte_size += 1; } let mut b: BitVec = diff --git a/lang/p4rs/src/table.rs b/lang/p4rs/src/table.rs index 54d33f79..535062e9 100644 --- a/lang/p4rs/src/table.rs +++ b/lang/p4rs/src/table.rs @@ -83,19 +83,16 @@ impl Key { } } -#[derive(Debug, Clone, PartialEq, Hash, Eq, Serialize, Deserialize)] +#[derive( + Debug, Clone, PartialEq, Hash, Eq, Serialize, Deserialize, Default, +)] pub enum Ternary { + #[default] DontCare, Value(BigUintKey), Masked(BigUint, BigUint, usize), } -impl Default for Ternary { - fn default() -> Self { - Self::DontCare - } -} - #[derive(Debug, Clone, PartialEq, Hash, Eq, Serialize, Deserialize)] pub struct Prefix { pub addr: IpAddr, diff --git a/p4/src/ast.rs b/p4/src/ast.rs index 19db75f5..5f52520f 100644 --- a/p4/src/ast.rs +++ b/p4/src/ast.rs @@ -47,7 +47,10 @@ impl AST { self.parsers.iter().find(|&p| p.name == name) } - pub fn get_user_defined_type(&self, name: &str) -> Option { + pub fn get_user_defined_type( + &self, + name: &str, + ) -> Option> { if let Some(user_struct) = self.get_struct(name) { return Some(UserDefinedType::Struct(user_struct)); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4bd1ff45..9cf77fc1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.86.0" +channel = "1.92.0" profile = "default"