Skip to content

Commit f6a3c2f

Browse files
Rollup merge of rust-lang#129494 - tshepang:fmt-threads-sendsync, r=Nadrieril
format code in tests/ui/threads-sendsync was thinking of fixing formatting for 1 test in the directory, but found a bunch of them to also be in need
2 parents c05e451 + 70ba8c1 commit f6a3c2f

Some content is hidden

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

54 files changed

+315
-247
lines changed

tests/ui/threads-sendsync/child-outlives-parent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use std::thread;
88

9-
fn child2(_s: String) { }
9+
fn child2(_s: String) {}
1010

1111
pub fn main() {
12-
let _x = thread::spawn(move|| child2("hi".to_string()));
12+
let _x = thread::spawn(move || child2("hi".to_string()));
1313
}

tests/ui/threads-sendsync/clone-with-exterior.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ use std::thread;
77

88
struct Pair {
99
a: isize,
10-
b: isize
10+
b: isize,
1111
}
1212

1313
pub fn main() {
14-
let z: Box<_> = Box::new(Pair { a : 10, b : 12});
14+
let z: Box<_> = Box::new(Pair { a: 10, b: 12 });
1515

16-
thread::spawn(move|| {
16+
thread::spawn(move || {
1717
assert_eq!(z.a, 10);
1818
assert_eq!(z.b, 12);
19-
}).join();
19+
})
20+
.join();
2021
}

tests/ui/threads-sendsync/comm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
#![allow(unused_must_use)]
33
//@ needs-threads
44

5-
use std::thread;
65
use std::sync::mpsc::{channel, Sender};
6+
use std::thread;
77

88
pub fn main() {
99
let (tx, rx) = channel();
10-
let t = thread::spawn(move || { child(&tx) });
10+
let t = thread::spawn(move || child(&tx));
1111
let y = rx.recv().unwrap();
1212
println!("received");
1313
println!("{}", y);

tests/ui/threads-sendsync/issue-24313.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
//@ needs-threads
33
//@ ignore-sgx no processes
44

5-
use std::thread;
6-
use std::env;
75
use std::process::Command;
6+
use std::{env, thread};
87

98
struct Handle(i32);
109

1110
impl Drop for Handle {
12-
fn drop(&mut self) { panic!(); }
11+
fn drop(&mut self) {
12+
panic!();
13+
}
1314
}
1415

1516
thread_local!(static HANDLE: Handle = Handle(0));
@@ -19,14 +20,15 @@ fn main() {
1920
if args.len() == 1 {
2021
let out = Command::new(&args[0]).arg("test").output().unwrap();
2122
let stderr = std::str::from_utf8(&out.stderr).unwrap();
22-
assert!(stderr.contains("explicit panic"),
23-
"bad failure message:\n{}\n", stderr);
23+
assert!(stderr.contains("explicit panic"), "bad failure message:\n{}\n", stderr);
2424
} else {
2525
// TLS dtors are not always run on process exit
2626
thread::spawn(|| {
2727
HANDLE.with(|h| {
2828
println!("{}", h.0);
2929
});
30-
}).join().unwrap();
30+
})
31+
.join()
32+
.unwrap();
3133
}
3234
}

tests/ui/threads-sendsync/issue-29488.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ fn main() {
1919
thread::spawn(|| {
2020
FOO.with(|_| {});
2121
println!("test1");
22-
}).join().unwrap();
22+
})
23+
.join()
24+
.unwrap();
2325
}

tests/ui/threads-sendsync/issue-4446.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ pub fn main() {
99

1010
tx.send("hello, world").unwrap();
1111

12-
thread::spawn(move|| {
12+
thread::spawn(move || {
1313
println!("{}", rx.recv().unwrap());
14-
}).join().ok().unwrap();
14+
})
15+
.join()
16+
.ok()
17+
.unwrap();
1518
}

tests/ui/threads-sendsync/issue-4448.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::thread;
77
pub fn main() {
88
let (tx, rx) = channel::<&'static str>();
99

10-
let t = thread::spawn(move|| {
10+
let t = thread::spawn(move || {
1111
assert_eq!(rx.recv().unwrap(), "hello, world");
1212
});
1313

tests/ui/threads-sendsync/issue-8827.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
//@ run-pass
22
//@ needs-threads
33

4-
use std::thread;
54
use std::sync::mpsc::{channel, Receiver};
5+
use std::thread;
66

77
fn periodical(n: isize) -> Receiver<bool> {
88
let (chan, port) = channel();
9-
thread::spawn(move|| {
9+
thread::spawn(move || {
1010
loop {
1111
for _ in 1..n {
1212
match chan.send(false) {
@@ -16,7 +16,7 @@ fn periodical(n: isize) -> Receiver<bool> {
1616
}
1717
match chan.send(true) {
1818
Ok(()) => {}
19-
Err(..) => break
19+
Err(..) => break,
2020
}
2121
}
2222
});
@@ -25,7 +25,7 @@ fn periodical(n: isize) -> Receiver<bool> {
2525

2626
fn integers() -> Receiver<isize> {
2727
let (chan, port) = channel();
28-
thread::spawn(move|| {
28+
thread::spawn(move || {
2929
let mut i = 1;
3030
loop {
3131
match chan.send(i) {
@@ -47,7 +47,7 @@ fn main() {
4747
(_, true, true) => println!("FizzBuzz"),
4848
(_, true, false) => println!("Fizz"),
4949
(_, false, true) => println!("Buzz"),
50-
(i, false, false) => println!("{}", i)
50+
(i, false, false) => println!("{}", i),
5151
}
5252
}
5353
}

tests/ui/threads-sendsync/issue-9396.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
#![allow(deprecated)]
44
//@ needs-threads
55

6-
use std::sync::mpsc::{TryRecvError, channel};
6+
use std::sync::mpsc::{channel, TryRecvError};
77
use std::thread;
88

99
pub fn main() {
1010
let (tx, rx) = channel();
11-
let t = thread::spawn(move||{
11+
let t = thread::spawn(move || {
1212
thread::sleep_ms(10);
1313
tx.send(()).unwrap();
1414
});
1515
loop {
1616
match rx.try_recv() {
1717
Ok(()) => break,
1818
Err(TryRecvError::Empty) => {}
19-
Err(TryRecvError::Disconnected) => unreachable!()
19+
Err(TryRecvError::Disconnected) => unreachable!(),
2020
}
2121
}
2222
t.join();

tests/ui/threads-sendsync/mpsc_stress.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22
//@ compile-flags:--test
33
//@ needs-threads
44

5-
use std::sync::mpsc::channel;
6-
use std::sync::mpsc::TryRecvError;
7-
use std::sync::mpsc::RecvError;
8-
use std::sync::mpsc::RecvTimeoutError;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
6+
use std::sync::mpsc::{channel, RecvError, RecvTimeoutError, TryRecvError};
97
use std::sync::Arc;
10-
use std::sync::atomic::AtomicUsize;
11-
use std::sync::atomic::Ordering;
12-
138
use std::thread;
149
use std::time::Duration;
1510

16-
1711
/// Simple thread synchronization utility
1812
struct Barrier {
1913
// Not using mutex/condvar for precision
@@ -42,7 +36,6 @@ impl Barrier {
4236
}
4337
}
4438

45-
4639
fn shared_close_sender_does_not_lose_messages_iter() {
4740
let (tb, rb) = Barrier::new2();
4841

@@ -71,7 +64,6 @@ fn shared_close_sender_does_not_lose_messages() {
7164
});
7265
}
7366

74-
7567
// https://github.com/rust-lang/rust/issues/39364
7668
fn concurrent_recv_timeout_and_upgrade_iter() {
7769
// 1 us
@@ -85,8 +77,8 @@ fn concurrent_recv_timeout_and_upgrade_iter() {
8577
match rx.recv_timeout(sleep) {
8678
Ok(_) => {
8779
break;
88-
},
89-
Err(_) => {},
80+
}
81+
Err(_) => {}
9082
}
9183
}
9284
});
@@ -105,7 +97,6 @@ fn concurrent_recv_timeout_and_upgrade() {
10597
});
10698
}
10799

108-
109100
fn concurrent_writes_iter() {
110101
const THREADS: usize = 4;
111102
const PER_THR: usize = 100;

0 commit comments

Comments
 (0)