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

Fix the compile error while running the cargo clippy #540

Merged
merged 2 commits into from
Mar 27, 2024
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
1 change: 0 additions & 1 deletion examples/single_mem_node/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::sync::mpsc::{self, RecvTimeoutError};
use std::thread;
use std::time::{Duration, Instant};

use raft::eraftpb::ConfState;
use raft::prelude::*;
use raft::storage::MemStorage;

Expand Down
4 changes: 2 additions & 2 deletions harness/tests/integration_cases/test_raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::panic::{self, AssertUnwindSafe};
use harness::*;
use protobuf::Message as PbMessage;
use raft::eraftpb::*;
use raft::storage::{GetEntriesContext, MemStorage};
use raft::storage::MemStorage;
use raft::*;
use raft_proto::*;
use slog::Logger;
Expand Down Expand Up @@ -5301,7 +5301,7 @@ fn test_election_with_priority_log() {
(false, false, true, 1, 1, 3, 1, StateRole::Leader),
];

for (_i, &(l1, l2, l3, p1, p2, p3, id, state)) in tests.iter().enumerate() {
for &(l1, l2, l3, p1, p2, p3, id, state) in tests.iter() {
let l = default_logger();
let mut n1 = new_test_raft(1, vec![1, 2, 3], 10, 1, new_storage(), &l);
let mut n2 = new_test_raft(2, vec![1, 2, 3], 10, 1, new_storage(), &l);
Expand Down
2 changes: 1 addition & 1 deletion harness/tests/integration_cases/test_raw_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use harness::Network;
use protobuf::{Message as PbMessage, ProtobufEnum as _};
use raft::eraftpb::*;
use raft::storage::{GetEntriesContext, MemStorage};
use raft::storage::MemStorage;
use raft::*;
use raft_proto::*;
use slog::Logger;
Expand Down
9 changes: 3 additions & 6 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// limitations under the License.

use std::cmp;
use std::convert::TryFrom;
use std::ops::{Deref, DerefMut};

use crate::eraftpb::{
Expand All @@ -24,8 +23,8 @@ use crate::eraftpb::{
};
use protobuf::Message as _;
use raft_proto::ConfChangeI;
use rand::{self, Rng};
use slog::{self, Logger};
use rand::Rng;
use slog::Logger;

#[cfg(feature = "failpoints")]
use fail::fail_point;
Expand Down Expand Up @@ -285,9 +284,7 @@ impl<T: Storage> DerefMut for Raft<T> {
}
}

trait AssertSend: Send {}

impl<T: Storage + Send> AssertSend for Raft<T> {}
impl<T: Storage + Send> Raft<T> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a wrong change. AssertSend is used to ensure Raft<T> is always Send.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fixing this. Sorry to miss.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for wrongly removing this constraint.


fn new_message(to: u64, field_type: MessageType, from: Option<u64>) -> Message {
let mut m = Message::default();
Expand Down
4 changes: 2 additions & 2 deletions src/raft_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ mod test {
fn test_unstable_ents() {
let l = default_logger();
let previous_ents = vec![new_entry(1, 1), new_entry(2, 2)];
let tests = vec![(3, vec![]), (1, previous_ents.clone())];
let tests = [(3, vec![]), (1, previous_ents.clone())];

for (i, &(unstable, ref wents)) in tests.iter().enumerate() {
// append stable entries to storage
Expand Down Expand Up @@ -1668,7 +1668,7 @@ mod test {
#[test]
fn test_compaction() {
let l = default_logger();
let tests = vec![
let tests = [
// out of upper bound
(1000, vec![1001u64], vec![0usize], true),
(
Expand Down
Loading