Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #126632 - Vonr:fix/moving-closure-formatting-v2, r=Ni…
Browse files Browse the repository at this point in the history
…lstrieb

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.
GuillaumeGomez authored Jun 18, 2024

Verified

This commit was signed with the committer’s verified signature.
2 parents 6ea41de + 7321e79 commit ef8c24a
Showing 6 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/typeck_root_ctxt.rs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ use std::ops::Deref;
/// e.g. closures defined within the function. For example:
/// ```ignore (illustrative)
/// fn foo() {
/// bar(move|| { ... })
/// bar(move || { ... })
/// }
/// ```
/// Here, the function `foo()` and the closure passed to
2 changes: 1 addition & 1 deletion library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
@@ -183,7 +183,7 @@
//!
//! let spinlock_clone = Arc::clone(&spinlock);
//!
//! let thread = thread::spawn(move|| {
//! let thread = thread::spawn(move || {
//! spinlock_clone.store(0, Ordering::Release);
//! });
//!
4 changes: 2 additions & 2 deletions library/std/src/sync/barrier.rs
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ use crate::sync::{Condvar, Mutex};
/// let c = Arc::clone(&barrier);
/// // The same messages will be printed together.
/// // You will NOT see any interleaving.
/// handles.push(thread::spawn(move|| {
/// handles.push(thread::spawn(move || {
/// println!("before wait");
/// c.wait();
/// println!("after wait");
@@ -115,7 +115,7 @@ impl Barrier {
/// let c = Arc::clone(&barrier);
/// // The same messages will be printed together.
/// // You will NOT see any interleaving.
/// handles.push(thread::spawn(move|| {
/// handles.push(thread::spawn(move || {
/// println!("before wait");
/// c.wait();
/// println!("after wait");
16 changes: 8 additions & 8 deletions library/std/src/sync/condvar.rs
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ impl WaitTimeoutResult {
/// let pair2 = Arc::clone(&pair);
///
/// // Inside of our lock, spawn a new thread, and then wait for it to start.
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut started = lock.lock().unwrap();
/// *started = true;
@@ -166,7 +166,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut started = lock.lock().unwrap();
/// *started = true;
@@ -221,7 +221,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut pending = lock.lock().unwrap();
/// *pending = false;
@@ -280,7 +280,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut started = lock.lock().unwrap();
/// *started = true;
@@ -352,7 +352,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut started = lock.lock().unwrap();
/// *started = true;
@@ -420,7 +420,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut pending = lock.lock().unwrap();
/// *pending = false;
@@ -484,7 +484,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut started = lock.lock().unwrap();
/// *started = true;
@@ -524,7 +524,7 @@ impl Condvar {
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
/// let pair2 = Arc::clone(&pair);
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// let (lock, cvar) = &*pair2;
/// let mut started = lock.lock().unwrap();
/// *started = true;
10 changes: 5 additions & 5 deletions library/std/src/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
//!
//! // Create a simple streaming channel
//! let (tx, rx) = channel();
//! thread::spawn(move|| {
//! thread::spawn(move || {
//! tx.send(10).unwrap();
//! });
//! assert_eq!(rx.recv().unwrap(), 10);
@@ -69,7 +69,7 @@
//! let (tx, rx) = channel();
//! for i in 0..10 {
//! let tx = tx.clone();
//! thread::spawn(move|| {
//! thread::spawn(move || {
//! tx.send(i).unwrap();
//! });
//! }
@@ -99,7 +99,7 @@
//! use std::sync::mpsc::sync_channel;
//!
//! let (tx, rx) = sync_channel::<i32>(0);
//! thread::spawn(move|| {
//! thread::spawn(move || {
//! // This will wait for the parent thread to start receiving
//! tx.send(53).unwrap();
//! });
@@ -510,7 +510,7 @@ pub enum TrySendError<T> {
/// let (sender, receiver) = channel();
///
/// // Spawn off an expensive computation
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// # fn expensive_computation() {}
/// sender.send(expensive_computation()).unwrap();
/// });
@@ -561,7 +561,7 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
/// // this returns immediately
/// sender.send(1).unwrap();
///
/// thread::spawn(move|| {
/// thread::spawn(move || {
/// // this will block until the previous message has been received
/// sender.send(2).unwrap();
/// });
2 changes: 1 addition & 1 deletion library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ use crate::fmt;
/// FOO.set(2);
///
/// // each thread starts out with the initial value of 1
/// let t = thread::spawn(move|| {
/// let t = thread::spawn(move || {
/// assert_eq!(FOO.get(), 1);
/// FOO.set(3);
/// });

0 comments on commit ef8c24a

Please sign in to comment.