From d24a66923b3922d4478a8c82816a4045536362f7 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 12 Mar 2026 20:34:22 +0000 Subject: [PATCH 1/2] chore: fix issues when compiling with Rust 2024 edition The code is still compatible with Rust 2021 after the changes. Signed-off-by: Wei Liu --- src/common/mod.rs | 10 +++++----- src/server.rs | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/common/mod.rs b/src/common/mod.rs index 56267b6..15366a5 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -343,12 +343,12 @@ mod tests { fn eq(&self, other: &Self) -> bool { use self::ConnectionError::*; match (self, other) { - (ParseError(ref e), ParseError(ref other_e)) => e.eq(other_e), + (ParseError(e), ParseError(other_e)) => e.eq(other_e), (ConnectionClosed, ConnectionClosed) => true, - (StreamReadError(ref e), StreamReadError(ref other_e)) => { + (StreamReadError(e), StreamReadError(other_e)) => { format!("{}", e).eq(&format!("{}", other_e)) } - (StreamWriteError(ref e), StreamWriteError(ref other_e)) => { + (StreamWriteError(e), StreamWriteError(other_e)) => { format!("{}", e).eq(&format!("{}", other_e)) } (InvalidWrite, InvalidWrite) => true, @@ -361,8 +361,8 @@ mod tests { fn eq(&self, other: &Self) -> bool { use self::ServerError::*; match (self, other) { - (ConnectionError(ref e), ConnectionError(ref other_e)) => e.eq(other_e), - (IOError(ref e), IOError(ref other_e)) => { + (ConnectionError(e), ConnectionError(other_e)) => e.eq(other_e), + (IOError(e), IOError(other_e)) => { e.raw_os_error() == other_e.raw_os_error() } (Overflow, Overflow) => true, diff --git a/src/server.rs b/src/server.rs index 6d51186..1eb90c5 100644 --- a/src/server.rs +++ b/src/server.rs @@ -298,7 +298,8 @@ impl HttpServer { /// # Errors /// Returns an `IOError` when `epoll::create` fails. pub unsafe fn new_from_fd(socket_fd: RawFd) -> Result { - let socket = UnixListener::from_raw_fd(socket_fd); + // Safety: see the safety contract of this function. + let socket = unsafe { UnixListener::from_raw_fd(socket_fd) }; let epoll = epoll::Epoll::new().map_err(ServerError::IOError)?; Ok(HttpServer { socket, From 3fdfb61f8ee26665ae71bf853d5ea16565155c73 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Thu, 12 Mar 2026 20:36:33 +0000 Subject: [PATCH 2/2] Update to Rust 2024 edition Signed-off-by: Wei Liu --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 63409dd..2baf048 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "micro_http" version = "0.1.0" license = "Apache-2.0" authors = ["Amazon Firecracker team "] -edition = "2021" +edition = "2024" [dependencies] libc = "0.2.66"