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.
This commit is contained in:
commit
7450ab7acb
@ -22,7 +22,7 @@
|
|||||||
/// e.g. closures defined within the function. For example:
|
/// e.g. closures defined within the function. For example:
|
||||||
/// ```ignore (illustrative)
|
/// ```ignore (illustrative)
|
||||||
/// fn foo() {
|
/// fn foo() {
|
||||||
/// bar(move|| { ... })
|
/// bar(move || { ... })
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// Here, the function `foo()` and the closure passed to
|
/// Here, the function `foo()` and the closure passed to
|
||||||
|
@ -183,7 +183,7 @@
|
|||||||
//!
|
//!
|
||||||
//! let spinlock_clone = Arc::clone(&spinlock);
|
//! let spinlock_clone = Arc::clone(&spinlock);
|
||||||
//!
|
//!
|
||||||
//! let thread = thread::spawn(move|| {
|
//! let thread = thread::spawn(move || {
|
||||||
//! spinlock_clone.store(0, Ordering::Release);
|
//! spinlock_clone.store(0, Ordering::Release);
|
||||||
//! });
|
//! });
|
||||||
//!
|
//!
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
/// let c = Arc::clone(&barrier);
|
/// let c = Arc::clone(&barrier);
|
||||||
/// // The same messages will be printed together.
|
/// // The same messages will be printed together.
|
||||||
/// // You will NOT see any interleaving.
|
/// // You will NOT see any interleaving.
|
||||||
/// handles.push(thread::spawn(move|| {
|
/// handles.push(thread::spawn(move || {
|
||||||
/// println!("before wait");
|
/// println!("before wait");
|
||||||
/// c.wait();
|
/// c.wait();
|
||||||
/// println!("after wait");
|
/// println!("after wait");
|
||||||
@ -115,7 +115,7 @@ pub const fn new(n: usize) -> Barrier {
|
|||||||
/// let c = Arc::clone(&barrier);
|
/// let c = Arc::clone(&barrier);
|
||||||
/// // The same messages will be printed together.
|
/// // The same messages will be printed together.
|
||||||
/// // You will NOT see any interleaving.
|
/// // You will NOT see any interleaving.
|
||||||
/// handles.push(thread::spawn(move|| {
|
/// handles.push(thread::spawn(move || {
|
||||||
/// println!("before wait");
|
/// println!("before wait");
|
||||||
/// c.wait();
|
/// c.wait();
|
||||||
/// println!("after wait");
|
/// println!("after wait");
|
||||||
|
@ -88,7 +88,7 @@ pub fn timed_out(&self) -> bool {
|
|||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// // Inside of our lock, spawn a new thread, and then wait for it to start.
|
/// // 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 (lock, cvar) = &*pair2;
|
||||||
/// let mut started = lock.lock().unwrap();
|
/// let mut started = lock.lock().unwrap();
|
||||||
/// *started = true;
|
/// *started = true;
|
||||||
@ -166,7 +166,7 @@ pub const fn new() -> Condvar {
|
|||||||
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut started = lock.lock().unwrap();
|
/// let mut started = lock.lock().unwrap();
|
||||||
/// *started = true;
|
/// *started = true;
|
||||||
@ -221,7 +221,7 @@ pub fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> LockResult<MutexGuard<'a,
|
|||||||
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut pending = lock.lock().unwrap();
|
/// let mut pending = lock.lock().unwrap();
|
||||||
/// *pending = false;
|
/// *pending = false;
|
||||||
@ -280,7 +280,7 @@ pub fn wait_while<'a, T, F>(
|
|||||||
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut started = lock.lock().unwrap();
|
/// let mut started = lock.lock().unwrap();
|
||||||
/// *started = true;
|
/// *started = true;
|
||||||
@ -352,7 +352,7 @@ pub fn wait_timeout_ms<'a, T>(
|
|||||||
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut started = lock.lock().unwrap();
|
/// let mut started = lock.lock().unwrap();
|
||||||
/// *started = true;
|
/// *started = true;
|
||||||
@ -420,7 +420,7 @@ pub fn wait_timeout<'a, T>(
|
|||||||
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(true), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut pending = lock.lock().unwrap();
|
/// let mut pending = lock.lock().unwrap();
|
||||||
/// *pending = false;
|
/// *pending = false;
|
||||||
@ -484,7 +484,7 @@ pub fn wait_timeout_while<'a, T, F>(
|
|||||||
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut started = lock.lock().unwrap();
|
/// let mut started = lock.lock().unwrap();
|
||||||
/// *started = true;
|
/// *started = true;
|
||||||
@ -524,7 +524,7 @@ pub fn notify_one(&self) {
|
|||||||
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
/// let pair = Arc::new((Mutex::new(false), Condvar::new()));
|
||||||
/// let pair2 = Arc::clone(&pair);
|
/// let pair2 = Arc::clone(&pair);
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// let (lock, cvar) = &*pair2;
|
/// let (lock, cvar) = &*pair2;
|
||||||
/// let mut started = lock.lock().unwrap();
|
/// let mut started = lock.lock().unwrap();
|
||||||
/// *started = true;
|
/// *started = true;
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
//!
|
//!
|
||||||
//! // Create a simple streaming channel
|
//! // Create a simple streaming channel
|
||||||
//! let (tx, rx) = channel();
|
//! let (tx, rx) = channel();
|
||||||
//! thread::spawn(move|| {
|
//! thread::spawn(move || {
|
||||||
//! tx.send(10).unwrap();
|
//! tx.send(10).unwrap();
|
||||||
//! });
|
//! });
|
||||||
//! assert_eq!(rx.recv().unwrap(), 10);
|
//! assert_eq!(rx.recv().unwrap(), 10);
|
||||||
@ -69,7 +69,7 @@
|
|||||||
//! let (tx, rx) = channel();
|
//! let (tx, rx) = channel();
|
||||||
//! for i in 0..10 {
|
//! for i in 0..10 {
|
||||||
//! let tx = tx.clone();
|
//! let tx = tx.clone();
|
||||||
//! thread::spawn(move|| {
|
//! thread::spawn(move || {
|
||||||
//! tx.send(i).unwrap();
|
//! tx.send(i).unwrap();
|
||||||
//! });
|
//! });
|
||||||
//! }
|
//! }
|
||||||
@ -99,7 +99,7 @@
|
|||||||
//! use std::sync::mpsc::sync_channel;
|
//! use std::sync::mpsc::sync_channel;
|
||||||
//!
|
//!
|
||||||
//! let (tx, rx) = sync_channel::<i32>(0);
|
//! let (tx, rx) = sync_channel::<i32>(0);
|
||||||
//! thread::spawn(move|| {
|
//! thread::spawn(move || {
|
||||||
//! // This will wait for the parent thread to start receiving
|
//! // This will wait for the parent thread to start receiving
|
||||||
//! tx.send(53).unwrap();
|
//! tx.send(53).unwrap();
|
||||||
//! });
|
//! });
|
||||||
@ -510,7 +510,7 @@ pub enum TrySendError<T> {
|
|||||||
/// let (sender, receiver) = channel();
|
/// let (sender, receiver) = channel();
|
||||||
///
|
///
|
||||||
/// // Spawn off an expensive computation
|
/// // Spawn off an expensive computation
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// # fn expensive_computation() {}
|
/// # fn expensive_computation() {}
|
||||||
/// sender.send(expensive_computation()).unwrap();
|
/// sender.send(expensive_computation()).unwrap();
|
||||||
/// });
|
/// });
|
||||||
@ -561,7 +561,7 @@ pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
|
|||||||
/// // this returns immediately
|
/// // this returns immediately
|
||||||
/// sender.send(1).unwrap();
|
/// sender.send(1).unwrap();
|
||||||
///
|
///
|
||||||
/// thread::spawn(move|| {
|
/// thread::spawn(move || {
|
||||||
/// // this will block until the previous message has been received
|
/// // this will block until the previous message has been received
|
||||||
/// sender.send(2).unwrap();
|
/// sender.send(2).unwrap();
|
||||||
/// });
|
/// });
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
/// FOO.set(2);
|
/// FOO.set(2);
|
||||||
///
|
///
|
||||||
/// // each thread starts out with the initial value of 1
|
/// // 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);
|
/// assert_eq!(FOO.get(), 1);
|
||||||
/// FOO.set(3);
|
/// FOO.set(3);
|
||||||
/// });
|
/// });
|
||||||
|
Loading…
Reference in New Issue
Block a user