Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all move|| with move || #126631

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
//! });
//!
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sync/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
16 changes: 8 additions & 8 deletions library/std/src/sync/condvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions library/std/src/sync/mpsc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
//! });
//! }
Expand Down Expand Up @@ -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();
//! });
Expand Down Expand Up @@ -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();
/// });
Expand Down Expand Up @@ -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();
/// });
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/thread/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/// });
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/array-slice-vec/slice-panic-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ fn foo() {
}

fn main() {
let _ = thread::spawn(move|| foo()).join();
let _ = thread::spawn(move || foo()).join();
unsafe { assert_eq!(DTOR_COUNT, 2); }
}
2 changes: 1 addition & 1 deletion tests/ui/array-slice-vec/slice-panic-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fn foo() {
}

fn main() {
let _ = thread::spawn(move|| foo()).join();
let _ = thread::spawn(move || foo()).join();
unsafe { assert_eq!(DTOR_COUNT, 2); }
}
4 changes: 2 additions & 2 deletions tests/ui/borrowck/borrowck-loan-blocks-move-cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn borrow<F>(v: &isize, f: F) where F: FnOnce(&isize) {
fn box_imm() {
let v: Box<_> = Box::new(3);
let w = &v;
thread::spawn(move|| {
thread::spawn(move || {
//~^ ERROR cannot move out of `v` because it is borrowed
println!("v={}", *v);
});
Expand All @@ -21,7 +21,7 @@ fn box_imm() {
fn box_imm_explicit() {
let v: Box<_> = Box::new(3);
let w = &v;
thread::spawn(move|| {
thread::spawn(move || {
//~^ ERROR cannot move
println!("v={}", *v);
});
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/borrowck/borrowck-loan-blocks-move-cc.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ LL | let v: Box<_> = Box::new(3);
| - binding `v` declared here
LL | let w = &v;
| -- borrow of `v` occurs here
LL | thread::spawn(move|| {
| ^^^^^^ move out of `v` occurs here
LL | thread::spawn(move || {
| ^^^^^^^ move out of `v` occurs here
LL |
LL | println!("v={}", *v);
| -- move occurs due to use in closure
Expand All @@ -27,8 +27,8 @@ LL | let v: Box<_> = Box::new(3);
| - binding `v` declared here
LL | let w = &v;
| -- borrow of `v` occurs here
LL | thread::spawn(move|| {
| ^^^^^^ move out of `v` occurs here
LL | thread::spawn(move || {
| ^^^^^^^ move out of `v` occurs here
LL |
LL | println!("v={}", *v);
| -- move occurs due to use in closure
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/borrowck/borrowck-move-moved-value-into-closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ fn call_f<F:FnOnce() -> isize>(f: F) -> isize {
fn main() {
let t: Box<_> = Box::new(3);

call_f(move|| { *t + 1 });
call_f(move|| { *t + 1 }); //~ ERROR use of moved value
call_f(move || { *t + 1 });
call_f(move || { *t + 1 }); //~ ERROR use of moved value
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ error[E0382]: use of moved value: `t`
LL | let t: Box<_> = Box::new(3);
| - move occurs because `t` has type `Box<isize>`, which does not implement the `Copy` trait
LL |
LL | call_f(move|| { *t + 1 });
| ------ -- variable moved due to use in closure
LL | call_f(move || { *t + 1 });
| ------- -- variable moved due to use in closure
| |
| value moved into closure here
LL | call_f(move|| { *t + 1 });
| ^^^^^^ -- use occurs due to use in closure
LL | call_f(move || { *t + 1 });
| ^^^^^^^ -- use occurs due to use in closure
| |
| value used here after move

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/borrowck/borrowck-multiple-captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn different_vars_after_borrows() {
let p1 = &x1;
let x2: Box<_> = Box::new(2);
let p2 = &x2;
thread::spawn(move|| {
thread::spawn(move || {
//~^ ERROR cannot move out of `x1` because it is borrowed
//~| ERROR cannot move out of `x2` because it is borrowed
drop(x1);
Expand All @@ -24,7 +24,7 @@ fn different_vars_after_moves() {
drop(x1);
let x2: Box<_> = Box::new(2);
drop(x2);
thread::spawn(move|| {
thread::spawn(move || {
//~^ ERROR use of moved value: `x1`
//~| ERROR use of moved value: `x2`
drop(x1);
Expand All @@ -35,7 +35,7 @@ fn different_vars_after_moves() {
fn same_var_after_borrow() {
let x: Box<_> = Box::new(1);
let p = &x;
thread::spawn(move|| {
thread::spawn(move || {
//~^ ERROR cannot move out of `x` because it is borrowed
drop(x);
drop(x); //~ ERROR use of moved value: `x`
Expand All @@ -46,7 +46,7 @@ fn same_var_after_borrow() {
fn same_var_after_move() {
let x: Box<_> = Box::new(1);
drop(x);
thread::spawn(move|| {
thread::spawn(move || {
//~^ ERROR use of moved value: `x`
drop(x);
drop(x); //~ ERROR use of moved value: `x`
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/borrowck/borrowck-multiple-captures.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ LL | let x1: Box<_> = Box::new(1);
LL | let p1 = &x1;
| --- borrow of `x1` occurs here
...
LL | thread::spawn(move|| {
| ^^^^^^ move out of `x1` occurs here
LL | thread::spawn(move || {
| ^^^^^^^ move out of `x1` occurs here
...
LL | drop(x1);
| -- move occurs due to use in closure
Expand All @@ -28,8 +28,8 @@ LL | let x2: Box<_> = Box::new(2);
| -- binding `x2` declared here
LL | let p2 = &x2;
| --- borrow of `x2` occurs here
LL | thread::spawn(move|| {
| ^^^^^^ move out of `x2` occurs here
LL | thread::spawn(move || {
| ^^^^^^^ move out of `x2` occurs here
...
LL | drop(x2);
| -- move occurs due to use in closure
Expand All @@ -51,8 +51,8 @@ LL | let x1: Box<_> = Box::new(1);
LL | drop(x1);
| -- value moved here
...
LL | thread::spawn(move|| {
| ^^^^^^ value used here after move
LL | thread::spawn(move || {
| ^^^^^^^ value used here after move
...
LL | drop(x1);
| -- use occurs due to use in closure
Expand All @@ -69,8 +69,8 @@ LL | let x2: Box<_> = Box::new(2);
| -- move occurs because `x2` has type `Box<i32>`, which does not implement the `Copy` trait
LL | drop(x2);
| -- value moved here
LL | thread::spawn(move|| {
| ^^^^^^ value used here after move
LL | thread::spawn(move || {
| ^^^^^^^ value used here after move
...
LL | drop(x2);
| -- use occurs due to use in closure
Expand All @@ -97,8 +97,8 @@ LL | let x: Box<_> = Box::new(1);
| - binding `x` declared here
LL | let p = &x;
| -- borrow of `x` occurs here
LL | thread::spawn(move|| {
| ^^^^^^ move out of `x` occurs here
LL | thread::spawn(move || {
| ^^^^^^^ move out of `x` occurs here
LL |
LL | drop(x);
| - move occurs due to use in closure
Expand Down Expand Up @@ -129,8 +129,8 @@ LL | let x: Box<_> = Box::new(1);
| - move occurs because `x` has type `Box<i32>`, which does not implement the `Copy` trait
LL | drop(x);
| - value moved here
LL | thread::spawn(move|| {
| ^^^^^^ value used here after move
LL | thread::spawn(move || {
| ^^^^^^^ value used here after move
LL |
LL | drop(x);
| - use occurs due to use in closure
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/borrowck/kindck-implicit-close-over-mut-var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn foo() {
// Here, i is *copied* into the proc (heap closure).
// Requires allocation. The proc's copy is not mutable.
let mut i = 0;
let t = thread::spawn(move|| {
let t = thread::spawn(move || {
user(i);
println!("spawned {}", i)
});
Expand All @@ -24,7 +24,7 @@ fn bar() {
// mutable outside of the proc.
let mut i = 0;
while i < 10 {
let t = thread::spawn(move|| {
let t = thread::spawn(move || {
user(i);
});
i += 1;
Expand All @@ -36,7 +36,7 @@ fn car() {
// Here, i must be shadowed in the proc to be mutable.
let mut i = 0;
while i < 10 {
let t = thread::spawn(move|| {
let t = thread::spawn(move || {
let mut i = i;
i += 1;
user(i);
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/box/unit/unique-send-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn main() {
let ts = (0..n).map(|i| {
expected += i;
let tx = tx.clone();
thread::spawn(move|| {
thread::spawn(move || {
child(&tx, i)
})
}).collect::<Vec<_>>();
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cannot-mutate-captured-non-mut-var.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ fn to_fn_once<A:std::marker::Tuple,F:FnOnce<A>>(f: F) -> F { f }

fn main() {
let x = 1;
to_fn_once(move|| { x = 2; });
to_fn_once(move || { x = 2; });
//~^ ERROR: cannot assign to `x`, as it is not declared as mutable

let s = std::io::stdin();
to_fn_once(move|| { s.read_to_end(&mut Vec::new()); });
to_fn_once(move || { s.read_to_end(&mut Vec::new()); });
//~^ ERROR: cannot borrow `s` as mutable, as it is not declared as mutable
}
Loading
Loading