Skip to content

Commit 9272591

Browse files
authored
refactor: move to rust edition 2024 (#1528)
* refactor: move rust edition 2024 * cargo fmt * enable lint for if let scope changes * add workspace lints + edition2024 lint * fix bad merge * wasm tests: install latest rustc version
1 parent 4b70c82 commit 9272591

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+197
-176
lines changed

.github/workflows/ci.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ jobs:
107107

108108
- uses: actions/[email protected]
109109

110-
- name: Install Rust 1.81.0 toolchain
110+
- name: Install Rust 1.85.0 toolchain
111111
uses: actions-rs/[email protected]
112112
with:
113113
profile: minimal
114114
# Check that jsonrpsee compiles with MSRV
115-
toolchain: 1.81
115+
toolchain: 1.85
116116
override: true
117117

118118
- name: Rust Cache
@@ -200,6 +200,13 @@ jobs:
200200
steps:
201201
- uses: actions/[email protected]
202202

203+
- name: Install Rust stable toolchain
204+
uses: actions-rs/[email protected]
205+
with:
206+
profile: minimal
207+
toolchain: stable
208+
override: true
209+
203210
- name: Install wasm-pack
204211
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
205212

Cargo.toml

+9-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ members = [
1616
"tests/proc-macro-core",
1717
"types",
1818
]
19-
resolver = "2"
19+
resolver = "3"
2020

2121
[workspace.package]
2222
authors = ["Parity Technologies <[email protected]>", "Pierre Krieger <[email protected]>"]
2323
version = "0.24.7"
24-
edition = "2021"
25-
rust-version = "1.81.0"
24+
edition = "2024"
25+
rust-version = "1.85.0"
2626
license = "MIT"
2727
repository = "https://github.com/paritytech/jsonrpsee"
2828
documentation = "https://docs.rs/jsonrpsee"
@@ -92,3 +92,9 @@ pprof = { version = "0.14", features = ["flamegraph", "criterion"] }
9292
socket2 = "0.5.1"
9393
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
9494
trybuild = "1.0.97"
95+
96+
[workspace.lints.rust]
97+
rust_2024_compatibility = { level = "warn", priority = -1 }
98+
missing_docs = { level = "warn", priority = -1 }
99+
missing_debug_implementations = { level = "warn", priority = -1 }
100+
missing_copy_implementations = { level = "warn", priority = -1 }

benches/bench.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::sync::Arc;
22
use std::time::Duration;
33

44
use criterion::*;
5-
use futures_util::future::{join_all, FutureExt};
5+
use futures_util::future::{FutureExt, join_all};
66
use futures_util::stream::FuturesUnordered;
77
use helpers::fixed_client::{
8-
http_client, rpc_params, ws_client, ws_handshake, ArrayParams, BatchRequestBuilder, ClientT, HeaderMap,
9-
SubscriptionClientT,
8+
ArrayParams, BatchRequestBuilder, ClientT, HeaderMap, SubscriptionClientT, http_client, rpc_params, ws_client,
9+
ws_handshake,
1010
};
1111
use helpers::{KIB, SUB_METHOD_NAME, UNSUB_METHOD_NAME};
1212
use jsonrpsee::types::{Id, RequestSer};

client/http-client/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ keywords.workspace = true
1313
readme.workspace = true
1414
publish = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720
async-trait = { workspace = true }
1821
base64 = { workspace = true }

client/http-client/src/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use async_trait::async_trait;
3636
use hyper::body::Bytes;
3737
use hyper::http::HeaderMap;
3838
use jsonrpsee_core::client::{
39-
generate_batch_id_range, BatchResponse, ClientT, Error, IdKind, RequestIdManager, Subscription, SubscriptionClientT,
39+
BatchResponse, ClientT, Error, IdKind, RequestIdManager, Subscription, SubscriptionClientT, generate_batch_id_range,
4040
};
4141
use jsonrpsee_core::params::BatchRequestBuilder;
4242
use jsonrpsee_core::traits::ToRpcParams;

client/http-client/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
//! which is not compatible with other async runtimes such as
3333
//! [`async-std`](https://docs.rs/async-std/), [`smol`](https://docs.rs/smol) and similar.
3434
35-
#![warn(missing_docs, missing_debug_implementations, missing_copy_implementations, unreachable_pub)]
3635
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
3736
#![cfg_attr(docsrs, feature(doc_cfg))]
3837

client/http-client/src/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2525
// DEALINGS IN THE SOFTWARE.
2626

27-
use crate::types::error::{ErrorCode, ErrorObject};
2827
use crate::HttpClientBuilder;
28+
use crate::types::error::{ErrorCode, ErrorObject};
29+
use jsonrpsee_core::ClientError;
2930
use jsonrpsee_core::client::{BatchResponse, ClientT, IdKind};
3031
use jsonrpsee_core::params::BatchRequestBuilder;
31-
use jsonrpsee_core::ClientError;
32-
use jsonrpsee_core::{rpc_params, DeserializeOwned};
32+
use jsonrpsee_core::{DeserializeOwned, rpc_params};
33+
use jsonrpsee_test_utils::TimeoutFutureExt;
3334
use jsonrpsee_test_utils::helpers::*;
3435
use jsonrpsee_test_utils::mocks::Id;
35-
use jsonrpsee_test_utils::TimeoutFutureExt;
3636
use jsonrpsee_types::error::ErrorObjectOwned;
3737

3838
fn init_logger() {

client/http-client/src/transport.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
use base64::Engine;
1010
use hyper::body::Bytes;
1111
use hyper::http::{HeaderMap, HeaderValue};
12-
use hyper_util::client::legacy::connect::HttpConnector;
1312
use hyper_util::client::legacy::Client;
13+
use hyper_util::client::legacy::connect::HttpConnector;
1414
use hyper_util::rt::TokioExecutor;
15-
use jsonrpsee_core::tracing::client::{rx_log_from_bytes, tx_log_from_str};
1615
use jsonrpsee_core::BoxError;
16+
use jsonrpsee_core::tracing::client::{rx_log_from_bytes, tx_log_from_str};
1717
use jsonrpsee_core::{
18-
http_helpers::{self, HttpError},
1918
TEN_MB_SIZE_BYTES,
19+
http_helpers::{self, HttpError},
2020
};
2121
use std::future::Future;
2222
use std::pin::Pin;

client/transport/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ keywords.workspace = true
1313
readme.workspace = true
1414
publish = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720
jsonrpsee-core = { workspace = true, features = ["client"] }
1821
tracing = { workspace = true }

client/transport/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2525
// DEALINGS IN THE SOFTWARE.
2626

27-
#![warn(missing_debug_implementations, missing_docs, unreachable_pub)]
2827
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
2928
#![cfg_attr(docsrs, feature(doc_cfg))]
3029

client/transport/src/web.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::fmt;
33
use futures_channel::mpsc;
44
use futures_util::sink::SinkExt;
55
use futures_util::stream::{SplitSink, SplitStream, StreamExt};
6-
use gloo_net::websocket::{futures::WebSocket, Message, WebSocketError};
6+
use gloo_net::websocket::{Message, WebSocketError, futures::WebSocket};
77
use jsonrpsee_core::async_trait;
88
use jsonrpsee_core::client::{ReceivedMessage, TransportReceiverT, TransportSenderT};
99

client/transport/src/ws/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ use std::time::Duration;
3232

3333
use base64::Engine;
3434
use futures_util::io::{BufReader, BufWriter};
35-
use jsonrpsee_core::client::{MaybeSend, ReceivedMessage, TransportReceiverT, TransportSenderT};
3635
use jsonrpsee_core::TEN_MB_SIZE_BYTES;
37-
use jsonrpsee_core::{async_trait, Cow};
36+
use jsonrpsee_core::client::{MaybeSend, ReceivedMessage, TransportReceiverT, TransportSenderT};
37+
use jsonrpsee_core::{Cow, async_trait};
3838
use soketto::connection::CloseReason;
3939
use soketto::connection::Error::Utf8;
4040
use soketto::data::ByteSlice125;
4141
use soketto::handshake::client::{Client as WsHandshakeClient, ServerResponse};
42-
use soketto::{connection, Data, Incoming};
42+
use soketto::{Data, Incoming, connection};
4343
use thiserror::Error;
4444
use tokio::net::TcpStream;
4545
use tokio_util::compat::{Compat, TokioAsyncReadCompatExt};
4646

47-
pub use http::{uri::InvalidUri, HeaderMap, HeaderValue, Uri};
47+
pub use http::{HeaderMap, HeaderValue, Uri, uri::InvalidUri};
4848
pub use soketto::handshake::client::Header;
4949
pub use stream::EitherStream;
5050
pub use tokio::io::{AsyncRead, AsyncWrite};
@@ -428,7 +428,9 @@ impl WsTransportClientBuilder {
428428
match target.path_and_query.rfind('/') {
429429
Some(offset) => target.path_and_query.replace_range(offset + 1.., &location),
430430
None => {
431-
let e = format!("path_and_query: {location}; this is a bug it must contain `/` please open issue");
431+
let e = format!(
432+
"path_and_query: {location}; this is a bug it must contain `/` please open issue"
433+
);
432434
err = Some(Err(WsHandshakeError::Url(e.into())));
433435
continue;
434436
}
@@ -638,13 +640,13 @@ fn build_tls_config(cert_store: &CertificateStore) -> Result<tokio_rustls::TlsCo
638640
use rustls_platform_verifier::ConfigVerifierExt;
639641

640642
rustls::ClientConfig::with_platform_verifier()
641-
},
643+
}
642644
#[cfg(not(feature = "tls-rustls-platform-verifier"))]
643645
CertificateStore::Native => {
644646
return Err(WsHandshakeError::CertificateStore(io::Error::new(
645647
io::ErrorKind::Other,
646648
"Native certificate store not supported, either call `Builder::with_custom_cert_store` or enable the `tls-rustls-platform-verifier` feature.",
647-
)))
649+
)));
648650
}
649651
CertificateStore::Custom(cfg) => cfg.clone(),
650652
};

client/wasm-client/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ keywords.workspace = true
1313
readme.workspace = true
1414
publish = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[target.'cfg(target_arch = "wasm32")'.dependencies]
1720
jsonrpsee-types = { workspace = true }
1821
jsonrpsee-client-transport = { workspace = true, features = ["web"] }

client/wasm-client/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
//! # jsonrpsee-wasm-client
2828
29-
#![warn(missing_docs, missing_debug_implementations, missing_copy_implementations, unreachable_pub)]
3029
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
3130
#![cfg_attr(docsrs, feature(doc_cfg))]
3231
#![cfg(target_arch = "wasm32")]

client/ws-client/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ keywords.workspace = true
1313
readme.workspace = true
1414
publish = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720
http = { workspace = true }
1821
jsonrpsee-types = { workspace = true }

client/ws-client/src/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,20 @@
3232
//!
3333
//! This library uses `tokio` as the runtime and does not support other runtimes.
3434
35-
#![warn(missing_docs, missing_debug_implementations, missing_copy_implementations, unreachable_pub)]
3635
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
3736
#![cfg_attr(docsrs, feature(doc_cfg))]
3837

3938
#[cfg(test)]
4039
mod tests;
4140

4241
pub use http::{HeaderMap, HeaderValue};
43-
pub use jsonrpsee_core::client::async_client::PingConfig;
4442
pub use jsonrpsee_core::client::Client as WsClient;
43+
pub use jsonrpsee_core::client::async_client::PingConfig;
4544
pub use jsonrpsee_types as types;
4645

4746
use jsonrpsee_client_transport::ws::{AsyncRead, AsyncWrite, WsTransportClientBuilder};
48-
use jsonrpsee_core::client::{ClientBuilder, Error, IdKind, MaybeSend, TransportReceiverT, TransportSenderT};
4947
use jsonrpsee_core::TEN_MB_SIZE_BYTES;
48+
use jsonrpsee_core::client::{ClientBuilder, Error, IdKind, MaybeSend, TransportReceiverT, TransportSenderT};
5049
use std::time::Duration;
5150
use url::Url;
5251

client/ws-client/src/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2525
// DEALINGS IN THE SOFTWARE.
2626

27-
use crate::types::error::{ErrorCode, ErrorObject};
2827
use crate::WsClientBuilder;
28+
use crate::types::error::{ErrorCode, ErrorObject};
2929

3030
use jsonrpsee_core::client::{
3131
BatchResponse, ClientT, Error, IdKind, Subscription, SubscriptionClientT, SubscriptionCloseReason,
3232
};
3333
use jsonrpsee_core::params::BatchRequestBuilder;
34-
use jsonrpsee_core::{rpc_params, DeserializeOwned};
34+
use jsonrpsee_core::{DeserializeOwned, rpc_params};
35+
use jsonrpsee_test_utils::TimeoutFutureExt;
3536
use jsonrpsee_test_utils::helpers::*;
3637
use jsonrpsee_test_utils::mocks::{Id, WebSocketTestServer};
37-
use jsonrpsee_test_utils::TimeoutFutureExt;
3838
use jsonrpsee_types::error::ErrorObjectOwned;
3939
use jsonrpsee_types::{Notification, SubscriptionId, SubscriptionPayload, SubscriptionResponse};
4040
use serde_json::Value as JsonValue;

core/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ keywords.workspace = true
1313
readme.workspace = true
1414
publish = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[dependencies]
1720
async-trait = { workspace = true }
1821
jsonrpsee-types = { workspace = true }

core/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
//! Shared utilities for `jsonrpsee`.
2828
29-
#![warn(missing_docs, missing_debug_implementations, missing_copy_implementations, unreachable_pub)]
3029
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
3130
#![cfg_attr(docsrs, feature(doc_cfg))]
3231

@@ -87,10 +86,10 @@ pub mod __reexports {
8786
pub use super::proc_macros_support::*;
8887
}
8988

90-
pub use serde::{de::DeserializeOwned, Serialize};
89+
pub use serde::{Serialize, de::DeserializeOwned};
9190
pub use serde_json::{
92-
to_value as to_json_value, value::to_raw_value as to_json_raw_value, value::RawValue as JsonRawValue,
93-
Value as JsonValue,
91+
Value as JsonValue, to_value as to_json_value, value::RawValue as JsonRawValue,
92+
value::to_raw_value as to_json_raw_value,
9493
};
9594
pub use std::borrow::Cow;
9695

core/src/params.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@ impl Default for ObjectParams {
164164

165165
impl ToRpcParams for ObjectParams {
166166
fn to_rpc_params(self) -> Result<Option<Box<RawValue>>, serde_json::Error> {
167-
if let Some(json) = self.0.build() {
168-
RawValue::from_string(json).map(Some)
169-
} else {
170-
Ok(None)
171-
}
167+
if let Some(json) = self.0.build() { RawValue::from_string(json).map(Some) } else { Ok(None) }
172168
}
173169
}
174170

@@ -210,11 +206,7 @@ impl Default for ArrayParams {
210206

211207
impl ToRpcParams for ArrayParams {
212208
fn to_rpc_params(self) -> Result<Option<Box<RawValue>>, serde_json::Error> {
213-
if let Some(json) = self.0.build() {
214-
RawValue::from_string(json).map(Some)
215-
} else {
216-
Ok(None)
217-
}
209+
if let Some(json) = self.0.build() { RawValue::from_string(json).map(Some) } else { Ok(None) }
218210
}
219211
}
220212

@@ -246,11 +238,7 @@ impl<'a> BatchRequestBuilder<'a> {
246238
/// Finish the building process and return a valid batch parameter.
247239
#[allow(clippy::type_complexity)]
248240
pub fn build(self) -> Result<Vec<(&'a str, Option<Box<RawValue>>)>, EmptyBatchRequest> {
249-
if self.0.is_empty() {
250-
Err(EmptyBatchRequest)
251-
} else {
252-
Ok(self.0)
253-
}
241+
if self.0.is_empty() { Err(EmptyBatchRequest) } else { Ok(self.0) }
254242
}
255243

256244
/// Get an iterator over the batch request.

examples/examples/client_subscription_drop_oldest_item.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use std::net::SocketAddr;
2828
use std::time::Duration;
2929

3030
use futures::{Stream, StreamExt};
31-
use jsonrpsee::core::client::{Subscription, SubscriptionClientT};
3231
use jsonrpsee::core::DeserializeOwned;
32+
use jsonrpsee::core::client::{Subscription, SubscriptionClientT};
3333
use jsonrpsee::rpc_params;
3434
use jsonrpsee::server::{RpcModule, Server, SubscriptionMessage};
3535
use jsonrpsee::ws_client::WsClientBuilder;
36-
use tokio_stream::wrappers::errors::BroadcastStreamRecvError;
3736
use tokio_stream::wrappers::BroadcastStream;
37+
use tokio_stream::wrappers::errors::BroadcastStreamRecvError;
3838

3939
#[tokio::main]
4040
async fn main() -> anyhow::Result<()> {

examples/examples/http.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ use jsonrpsee::core::client::ClientT;
3232
use jsonrpsee::http_client::HttpClient;
3333
use jsonrpsee::rpc_params;
3434
use jsonrpsee::server::{RpcModule, Server};
35-
use tower_http::trace::{DefaultMakeSpan, DefaultOnResponse, TraceLayer};
3635
use tower_http::LatencyUnit;
36+
use tower_http::trace::{DefaultMakeSpan, DefaultOnResponse, TraceLayer};
3737
use tracing_subscriber::util::SubscriberInitExt;
3838

3939
#[tokio::main]

0 commit comments

Comments
 (0)