From a59f3c4c1f271bad6fafd0431568408e5f739b4e Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Wed, 13 Dec 2023 17:49:05 -0800 Subject: [PATCH] Fix min dependency versions. Update MSRV to 1.64. Also includes a work-around for a buggy `format_args!` macro found in rustc 1.67 and 1.68. Resolves #2670. --- contrib/db_pools/codegen/Cargo.toml | 2 +- contrib/db_pools/lib/Cargo.toml | 2 +- contrib/dyn_templates/Cargo.toml | 2 +- contrib/sync_db_pools/codegen/Cargo.toml | 2 +- contrib/sync_db_pools/lib/Cargo.toml | 4 ++-- contrib/ws/Cargo.toml | 2 +- contrib/ws/src/websocket.rs | 4 ++-- core/codegen/Cargo.toml | 4 ++-- core/http/Cargo.toml | 4 ++-- core/lib/Cargo.toml | 6 +++--- core/lib/build.rs | 10 ++++++++-- core/lib/src/server.rs | 6 +++++- 12 files changed, 29 insertions(+), 19 deletions(-) diff --git a/contrib/db_pools/codegen/Cargo.toml b/contrib/db_pools/codegen/Cargo.toml index 35176dc1..713b5a1f 100644 --- a/contrib/db_pools/codegen/Cargo.toml +++ b/contrib/db_pools/codegen/Cargo.toml @@ -8,7 +8,7 @@ readme = "../README.md" keywords = ["rocket", "framework", "database", "pools"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [lib] proc-macro = true diff --git a/contrib/db_pools/lib/Cargo.toml b/contrib/db_pools/lib/Cargo.toml index 5beb44fb..9dfdfa23 100644 --- a/contrib/db_pools/lib/Cargo.toml +++ b/contrib/db_pools/lib/Cargo.toml @@ -8,7 +8,7 @@ readme = "../README.md" keywords = ["rocket", "framework", "database", "pools"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [package.metadata.docs.rs] all-features = true diff --git a/contrib/dyn_templates/Cargo.toml b/contrib/dyn_templates/Cargo.toml index d08fabdb..11650b4e 100644 --- a/contrib/dyn_templates/Cargo.toml +++ b/contrib/dyn_templates/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" keywords = ["rocket", "framework", "templates", "templating", "engine"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [features] tera = ["tera_"] diff --git a/contrib/sync_db_pools/codegen/Cargo.toml b/contrib/sync_db_pools/codegen/Cargo.toml index 007c8f2b..1f30eb32 100644 --- a/contrib/sync_db_pools/codegen/Cargo.toml +++ b/contrib/sync_db_pools/codegen/Cargo.toml @@ -8,7 +8,7 @@ readme = "../README.md" keywords = ["rocket", "framework", "database", "pools"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [lib] proc-macro = true diff --git a/contrib/sync_db_pools/lib/Cargo.toml b/contrib/sync_db_pools/lib/Cargo.toml index 452be35b..b563e48d 100644 --- a/contrib/sync_db_pools/lib/Cargo.toml +++ b/contrib/sync_db_pools/lib/Cargo.toml @@ -8,7 +8,7 @@ readme = "../README.md" keywords = ["rocket", "framework", "database", "pools"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [features] diesel_sqlite_pool = ["diesel/sqlite", "diesel/r2d2"] @@ -31,7 +31,7 @@ r2d2_postgres = { version = "0.18", optional = true } rusqlite = { version = "0.29.0", optional = true } r2d2_sqlite = { version = "0.22.0", optional = true } -memcache = { version = "0.15", optional = true } +memcache = { version = "0.15.2", optional = true } r2d2-memcache = { version = "0.6", optional = true } [dependencies.rocket_sync_db_pools_codegen] diff --git a/contrib/ws/Cargo.toml b/contrib/ws/Cargo.toml index 2bb2a031..91fdf67f 100644 --- a/contrib/ws/Cargo.toml +++ b/contrib/ws/Cargo.toml @@ -10,7 +10,7 @@ readme = "README.md" keywords = ["rocket", "web", "framework", "websocket"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [features] default = ["tungstenite"] diff --git a/contrib/ws/src/websocket.rs b/contrib/ws/src/websocket.rs index 32b598e8..63414a11 100644 --- a/contrib/ws/src/websocket.rs +++ b/contrib/ws/src/websocket.rs @@ -245,8 +245,8 @@ impl<'r, S> IoHandler for MessageStream<'r, S> { async fn io(self: Pin>, io: IoStream) -> io::Result<()> { let (mut sink, source) = DuplexStream::new(io, self.ws.config).await.split(); - let handler = Pin::into_inner(self).handler; - let mut stream = std::pin::pin!((handler)(source)); + let stream = (Pin::into_inner(self).handler)(source); + rocket::tokio::pin!(stream); while let Some(msg) = stream.next().await { let result = match msg { Ok(msg) => sink.send(msg).await, diff --git a/core/codegen/Cargo.toml b/core/codegen/Cargo.toml index 9fffcb3c..d967b0a4 100644 --- a/core/codegen/Cargo.toml +++ b/core/codegen/Cargo.toml @@ -10,7 +10,7 @@ readme = "../../README.md" keywords = ["rocket", "web", "framework", "code", "generation"] license = "MIT OR Apache-2.0" edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [lib] proc-macro = true @@ -19,7 +19,7 @@ proc-macro = true indexmap = "2" quote = "1.0" syn = { version = "2.0", features = ["full", "visit", "visit-mut", "extra-traits"] } -proc-macro2 = "1.0.27" +proc-macro2 = "1.0.60" devise = "0.4" rocket_http = { version = "0.6.0-dev", path = "../http/" } unicode-xid = "0.2" diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml index 7200b6bd..9aa6a726 100644 --- a/core/http/Cargo.toml +++ b/core/http/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["rocket", "web", "framework", "http"] license = "MIT OR Apache-2.0" categories = ["web-programming"] edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [features] default = [] @@ -38,7 +38,7 @@ log = "0.4" ref-cast = "1.0" uncased = "0.9.6" either = "1" -pear = "0.2.3" +pear = "0.2.8" pin-project-lite = "0.2" memchr = "2" stable-pattern = "0.1" diff --git a/core/lib/Cargo.toml b/core/lib/Cargo.toml index d7becfe2..01b2b370 100644 --- a/core/lib/Cargo.toml +++ b/core/lib/Cargo.toml @@ -14,7 +14,7 @@ license = "MIT OR Apache-2.0" build = "build.rs" categories = ["web-programming::http-server"] edition = "2021" -rust-version = "1.56" +rust-version = "1.64" [package.metadata.docs.rs] all-features = true @@ -46,7 +46,7 @@ binascii = "0.1" ref-cast = "1.0" atomic = "0.5" parking_lot = "0.12" -ubyte = {version = "0.10", features = ["serde"] } +ubyte = {version = "0.10.2", features = ["serde"] } serde = { version = "1.0", features = ["derive"] } figment = { version = "0.10.6", features = ["toml", "env"] } rand = "0.8" @@ -56,7 +56,7 @@ indexmap = { version = "2", features = ["serde"] } tempfile = "3" async-trait = "0.1.43" async-stream = "0.3.2" -multer = { version = "2", features = ["tokio-io"] } +multer = { version = "3.0.0", features = ["tokio-io"] } tokio-stream = { version = "0.1.6", features = ["signal", "time"] } state = "0.6" diff --git a/core/lib/build.rs b/core/lib/build.rs index 99369685..c72f4955 100644 --- a/core/lib/build.rs +++ b/core/lib/build.rs @@ -1,5 +1,11 @@ fn main() { - if let Some(true) = version_check::is_feature_flaggable() { - println!("cargo:rustc-cfg=nightly"); + if let Some((version, channel, _)) = version_check::triple() { + if channel.supports_features() { + println!("cargo:rustc-cfg=nightly"); + } + + if version.at_least("1.67") && version.at_most("1.68.2") { + println!("cargo:rustc-cfg=broken_fmt"); + } } } diff --git a/core/lib/src/server.rs b/core/lib/src/server.rs index 800c9dbe..a8b5d6a4 100644 --- a/core/lib/src/server.rs +++ b/core/lib/src/server.rs @@ -73,7 +73,9 @@ async fn hyper_service_fn( // sends the response metadata (and a body channel) prior. let (tx, rx) = oneshot::channel(); - debug!("Received request: {:#?}", hyp_req); + #[cfg(not(broken_fmt))] + debug!("received request: {:#?}", hyp_req); + tokio::spawn(async move { // We move the request next, so get the upgrade future now. let pending_upgrade = hyper::upgrade::on(&mut hyp_req); @@ -160,7 +162,9 @@ impl Rocket { let hyp_response = hyp_res.body(hyp_body) .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + #[cfg(not(broken_fmt))] debug!("sending response: {:#?}", hyp_response); + tx.send(hyp_response).map_err(|_| { let msg = "client disconnect before response started"; io::Error::new(io::ErrorKind::BrokenPipe, msg)