Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: fix feature specific lint warnings #1257

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
#[allow(deprecated)] // since nightly 1.82
use std::panic::PanicInfo;
use std::panic::PanicHookInfo;
use std::time::Duration;

use openraft::BasicNode;
Expand All @@ -13,8 +12,7 @@ use tokio::task;
use tokio::task::LocalSet;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)] // PanicInfo deprecated since nightly 1.82
pub fn log_panic(panic: &PanicInfo) {
pub fn log_panic(panic: &PanicHookInfo) {
let backtrace = format!("{:?}", Backtrace::force_capture());

eprintln!("{}", panic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
use std::collections::HashMap;
#[allow(deprecated)] // since nightly 1.82
use std::panic::PanicInfo;
use std::panic::PanicHookInfo;
use std::time::Duration;

use openraft::BasicNode;
Expand All @@ -14,8 +13,7 @@ use tokio::task;
use tokio::task::LocalSet;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)] // PanicInfo deprecated since nightly 1.82
pub fn log_panic(panic: &PanicInfo) {
pub fn log_panic(panic: &PanicHookInfo) {
let backtrace = format!("{:?}", Backtrace::force_capture());

eprintln!("{}", panic);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
#[allow(deprecated)] // since nightly 1.82
use std::panic::PanicInfo;
use std::panic::PanicHookInfo;
use std::time::Duration;

use maplit::btreemap;
Expand All @@ -22,8 +21,7 @@ use tokio::task;
use tokio::task::LocalSet;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)] // PanicInfo deprecated since nightly 1.82
pub fn log_panic(panic: &PanicInfo) {
pub fn log_panic(panic: &PanicHookInfo) {
let backtrace = format!("{:?}", Backtrace::force_capture());

eprintln!("{}", panic);
Expand Down
6 changes: 2 additions & 4 deletions examples/raft-kv-memstore/tests/cluster/test_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
#[allow(deprecated)] // since nightly 1.82
use std::panic::PanicInfo;
use std::panic::PanicHookInfo;
use std::thread;
use std::time::Duration;

Expand All @@ -14,8 +13,7 @@ use raft_kv_memstore::store::Request;
use tokio::runtime::Runtime;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)] // PanicInfo deprecated since nightly 1.82
pub fn log_panic(panic: &PanicInfo) {
pub fn log_panic(panic: &PanicHookInfo) {
let backtrace = {
format!("{:?}", Backtrace::force_capture())
// #[cfg(feature = "bt")]
Expand Down
6 changes: 2 additions & 4 deletions examples/raft-kv-rocksdb/tests/cluster/test_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
#[allow(deprecated)] // since nightly 1.82
use std::panic::PanicInfo;
use std::panic::PanicHookInfo;
use std::thread;
use std::time::Duration;

Expand All @@ -14,8 +13,7 @@ use raft_kv_rocksdb::Node;
use tokio::runtime::Handle;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)] // PanicInfo deprecated since nightly 1.82
pub fn log_panic(panic: &PanicInfo) {
pub fn log_panic(panic: &PanicHookInfo) {
let backtrace = { format!("{:?}", Backtrace::force_capture()) };

eprintln!("{}", panic);
Expand Down
8 changes: 4 additions & 4 deletions openraft/src/core/tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ where C: RaftTypeConfig
}
}

// AsyncRuntime::spawn is `spawn_local` with singlethreaded enabled.
// It will result in a panic:
// `spawn_local` called from outside of a `task::LocalSet`.
#[cfg(not(feature = "singlethreaded"))]
#[cfg(test)]
mod tests {
use std::io::Cursor;
Expand All @@ -181,10 +185,6 @@ mod tests {
type Responder = crate::impls::OneshotResponder<Self>;
}

// AsyncRuntime::spawn is `spawn_local` with singlethreaded enabled.
// It will result in a panic:
// `spawn_local` called from outside of a `task::LocalSet`.
#[cfg(not(feature = "singlethreaded"))]
#[tokio::test]
async fn test_shutdown() -> anyhow::Result<()> {
let (tx, mut rx) = TickUTConfig::mpsc_unbounded();
Expand Down
2 changes: 1 addition & 1 deletion openraft/src/network/snapshot_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ pub trait SnapshotTransport<C: RaftTypeConfig> {
///
/// - The receiving state `streaming` is maintained by the caller.
/// - And it depends on `Raft::begin_receiving_snapshot()` to create a `SnapshotData` for
/// receiving data.
/// receiving data.
///
/// Example usage:
/// ```ignore
Expand Down
4 changes: 2 additions & 2 deletions openraft/src/network/v2/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ where C: RaftTypeConfig
/// [`Raft::handle_transfer_leader()`]: crate::raft::Raft::handle_transfer_leader
#[since(version = "0.10.0")]
async fn transfer_leader(&mut self, _req: TransferLeaderRequest<C>, _option: RPCOption) -> Result<(), RPCError<C>> {
return Err(RPCError::Unreachable(Unreachable::new(&AnyError::error(
Err(RPCError::Unreachable(Unreachable::new(&AnyError::error(
"transfer_leader not implemented",
))));
))))
}

/// Build a backoff instance if the target node is temporarily(or permanently) unreachable.
Expand Down
3 changes: 2 additions & 1 deletion openraft/src/vote/leader_id/leader_id_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ impl<NID: NodeId> CommittedLeaderId<NID> {
#[cfg(test)]
#[allow(clippy::nonminimal_bool)]
mod tests {
use crate::CommittedLeaderId;
use crate::LeaderId;

#[cfg(feature = "serde")]
#[test]
fn test_committed_leader_id_serde() -> anyhow::Result<()> {
use crate::CommittedLeaderId;

let c = CommittedLeaderId::<u32>::new(5, 10);
let s = serde_json::to_string(&c)?;
assert_eq!(r#"5"#, s);
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::collections::HashMap;
use std::env;
use std::fmt;
use std::future::Future;
use std::panic::PanicInfo;
use std::panic::PanicHookInfo;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
use std::sync::Arc;
Expand Down Expand Up @@ -142,7 +142,7 @@ pub fn set_panic_hook() {
}));
}

pub fn log_panic(panic: &PanicInfo) {
pub fn log_panic(panic: &PanicHookInfo) {
let backtrace = {
#[cfg(feature = "bt")]
{
Expand Down
Loading