Skip to content

Commit 68e12d3

Browse files
authored
Rollup merge of #126632 - Vonr:fix/moving-closure-formatting-v2, r=Nilstrieb
Replace `move||` with `move ||` Edit from #126631 to revert changes in `tests/ui`. There are 18 instances of `move||` across 6 files in the repo: - `compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs` - `library/core/src/sync/atomic.rs` - `library/std/src/sync/condvar.rs` - `library/std/src/sync/mpsc/mod.rs` - `library/std/src/sync/barrier.rs` - `library/std/src/thread/local.rs` I have replaced all such instances with `move ||` instead as it better adheres to modern formatting standards. Ideally, we would have this automated by rustfmt or some other tool, but I do not have the time to implement such a feature or tool. Nonetheless, I would encourage any effort invested into such a tool or feature.
2 parents 00df302 + 7321e79 commit 68e12d3

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use std::ops::Deref;
2222
/// e.g. closures defined within the function. For example:
2323
/// ```ignore (illustrative)
2424
/// fn foo() {
25-
/// bar(move|| { ... })
25+
/// bar(move || { ... })
2626
/// }
2727
/// ```
2828
/// Here, the function `foo()` and the closure passed to

library/core/src/sync/atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
//!
184184
//! let spinlock_clone = Arc::clone(&spinlock);
185185
//!
186-
//! let thread = thread::spawn(move|| {
186+
//! let thread = thread::spawn(move || {
187187
//! spinlock_clone.store(0, Ordering::Release);
188188
//! });
189189
//!

library/std/src/sync/barrier.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::sync::{Condvar, Mutex};
2020
/// let c = Arc::clone(&barrier);
2121
/// // The same messages will be printed together.
2222
/// // You will NOT see any interleaving.
23-
/// handles.push(thread::spawn(move|| {
23+
/// handles.push(thread::spawn(move || {
2424
/// println!("before wait");
2525
/// c.wait();
2626
/// println!("after wait");
@@ -115,7 +115,7 @@ impl Barrier {
115115
/// let c = Arc::clone(&barrier);
116116
/// // The same messages will be printed together.
117117
/// // You will NOT see any interleaving.
118-
/// handles.push(thread::spawn(move|| {
118+
/// handles.push(thread::spawn(move || {
119119
/// println!("before wait");
120120
/// c.wait();
121121
/// println!("after wait");

library/std/src/sync/condvar.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl WaitTimeoutResult {
8888
/// let pair2 = Arc::clone(&pair);
8989
///
9090
/// // Inside of our lock, spawn a new thread, and then wait for it to start.
91-
/// thread::spawn(move|| {
91+
/// thread::spawn(move || {
9292
/// let (lock, cvar) = &*pair2;
9393
/// let mut started = lock.lock().unwrap();
9494
/// *started = true;
@@ -166,7 +166,7 @@ impl Condvar {
166166
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
167167
/// let pair2 = Arc::clone(&pair);
168168
///
169-
/// thread::spawn(move|| {
169+
/// thread::spawn(move || {
170170
/// let (lock, cvar) = &*pair2;
171171
/// let mut started = lock.lock().unwrap();
172172
/// *started = true;
@@ -221,7 +221,7 @@ impl Condvar {
221221
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
222222
/// let pair2 = Arc::clone(&pair);
223223
///
224-
/// thread::spawn(move|| {
224+
/// thread::spawn(move || {
225225
/// let (lock, cvar) = &*pair2;
226226
/// let mut pending = lock.lock().unwrap();
227227
/// *pending = false;
@@ -280,7 +280,7 @@ impl Condvar {
280280
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
281281
/// let pair2 = Arc::clone(&pair);
282282
///
283-
/// thread::spawn(move|| {
283+
/// thread::spawn(move || {
284284
/// let (lock, cvar) = &*pair2;
285285
/// let mut started = lock.lock().unwrap();
286286
/// *started = true;
@@ -352,7 +352,7 @@ impl Condvar {
352352
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
353353
/// let pair2 = Arc::clone(&pair);
354354
///
355-
/// thread::spawn(move|| {
355+
/// thread::spawn(move || {
356356
/// let (lock, cvar) = &*pair2;
357357
/// let mut started = lock.lock().unwrap();
358358
/// *started = true;
@@ -420,7 +420,7 @@ impl Condvar {
420420
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
421421
/// let pair2 = Arc::clone(&pair);
422422
///
423-
/// thread::spawn(move|| {
423+
/// thread::spawn(move || {
424424
/// let (lock, cvar) = &*pair2;
425425
/// let mut pending = lock.lock().unwrap();
426426
/// *pending = false;
@@ -484,7 +484,7 @@ impl Condvar {
484484
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
485485
/// let pair2 = Arc::clone(&pair);
486486
///
487-
/// thread::spawn(move|| {
487+
/// thread::spawn(move || {
488488
/// let (lock, cvar) = &*pair2;
489489
/// let mut started = lock.lock().unwrap();
490490
/// *started = true;
@@ -524,7 +524,7 @@ impl Condvar {
524524
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
525525
/// let pair2 = Arc::clone(&pair);
526526
///
527-
/// thread::spawn(move|| {
527+
/// thread::spawn(move || {
528528
/// let (lock, cvar) = &*pair2;
529529
/// let mut started = lock.lock().unwrap();
530530
/// *started = true;

library/std/src/sync/mpsc/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//!
5252
//! // Create a simple streaming channel
5353
//! let (tx, rx) = channel();
54-
//! thread::spawn(move|| {
54+
//! thread::spawn(move || {
5555
//! tx.send(10).unwrap();
5656
//! });
5757
//! assert_eq!(rx.recv().unwrap(), 10);
@@ -69,7 +69,7 @@
6969
//! let (tx, rx) = channel();
7070
//! for i in 0..10 {
7171
//! let tx = tx.clone();
72-
//! thread::spawn(move|| {
72+
//! thread::spawn(move || {
7373
//! tx.send(i).unwrap();
7474
//! });
7575
//! }
@@ -99,7 +99,7 @@
9999
//! use std::sync::mpsc::sync_channel;
100100
//!
101101
//! let (tx, rx) = sync_channel::<i32>(0);
102-
//! thread::spawn(move|| {
102+
//! thread::spawn(move || {
103103
//! // This will wait for the parent thread to start receiving
104104
//! tx.send(53).unwrap();
105105
//! });
@@ -510,7 +510,7 @@ pub enum TrySendError<T> {
510510
/// let (sender, receiver) = channel();
511511
///
512512
/// // Spawn off an expensive computation
513-
/// thread::spawn(move|| {
513+
/// thread::spawn(move || {
514514
/// # fn expensive_computation() {}
515515
/// sender.send(expensive_computation()).unwrap();
516516
/// });
@@ -561,7 +561,7 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
561561
/// // this returns immediately
562562
/// sender.send(1).unwrap();
563563
///
564-
/// thread::spawn(move|| {
564+
/// thread::spawn(move || {
565565
/// // this will block until the previous message has been received
566566
/// sender.send(2).unwrap();
567567
/// });

library/std/src/thread/local.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ use crate::fmt;
6262
/// FOO.set(2);
6363
///
6464
/// // each thread starts out with the initial value of 1
65-
/// let t = thread::spawn(move|| {
65+
/// let t = thread::spawn(move || {
6666
/// assert_eq!(FOO.get(), 1);
6767
/// FOO.set(3);
6868
/// });

0 commit comments

Comments
 (0)