Skip to content

Commit 3983071

Browse files
committed
Exposes bug for rust-lang/rust#18490 in tests/node.rs:46 and
src/node.rs:133
1 parent 877e8e5 commit 3983071

File tree

4 files changed

+379
-384
lines changed

4 files changed

+379
-384
lines changed

src/intercommunication.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22
use std::io::timer::sleep;
33
use std::time::duration::Duration;
4-
use std::comm::{Disconnected, TryRecvError};
4+
use std::comm::Disconnected;
55

66
use std::sync::{Arc, Mutex};
77

src/node.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ extern crate time;
22

33
use std::io::timer::sleep;
44
use std::time::duration::Duration;
5-
use std::comm::{Disconnected, TryRecvError};
6-
7-
use std::sync::{Arc, Mutex};
5+
use std::comm::Disconnected;
86

97
use std::task::TaskBuilder;
108

@@ -147,7 +145,7 @@ impl Node {
147145
fn contact(&self) -> &NodeContact {
148146
match self.contact {
149147
Some(ref x) => x,
150-
None => fail!("You forgot to start the node")
148+
None => panic!("You forgot to start the node")
151149
}
152150
}
153151

@@ -175,7 +173,7 @@ impl NodeService {
175173
fn start_service(host: String, intercommunication: &mut Intercommunication) -> NodeContact {
176174
let (contact, service_contact) = NodeService::channels();
177175

178-
let mut comm = intercommunication.register(host.clone());
176+
let comm = intercommunication.register(host.clone());
179177

180178
TaskBuilder::new().named(format!("{}-service", host)).spawn(proc() {
181179
let mut me = NodeService::new(host, service_contact, comm);

tests/intercommunication.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ extern crate raft_rs;
33

44
mod using_dumb_network {
55

6-
use std::io::timer::sleep;
7-
use std::time::duration::Duration;
8-
9-
use raft_rs::intercommunication::{Intercommunication, DefaultIntercommunication, Package, Ack, Pack, start};
6+
use raft_rs::intercommunication::{Intercommunication, DefaultIntercommunication, Ack, Pack, start};
107

118
#[test]
129
fn sending_simple_ack() {
1310
let mut comm: DefaultIntercommunication = Intercommunication::new();
1411

15-
let mut comm_1 = comm.register("host_1".to_string());
16-
let mut comm_2 = comm.register("host_2".to_string());
12+
let comm_1 = comm.register("host_1".to_string());
13+
let comm_2 = comm.register("host_2".to_string());
1714

1815
let stop_comm = start(comm);
1916

@@ -24,7 +21,7 @@ mod using_dumb_network {
2421
assert_eq!(from, "host_1".to_string());
2522
assert_eq!(to, "host_2".to_string());
2623
},
27-
_ => fail!("No ack")
24+
_ => panic!("No ack")
2825
}
2926

3027
stop_comm.send(0);

0 commit comments

Comments
 (0)