From 9af07ce208059994b32117b248cc544803a13256 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 21 Jul 2019 02:43:19 +0900 Subject: [PATCH] chore: remove redundant field names in struct literals (#1334) --- tokio-codec/src/framed.rs | 4 ++-- tokio-codec/src/framed_read.rs | 4 ++-- tokio-codec/src/framed_write.rs | 7 ++----- tokio-current-thread/src/lib.rs | 4 ++-- tokio-current-thread/src/scheduler.rs | 4 ++-- tokio-fs/src/create_dir.rs | 2 +- tokio-fs/src/create_dir_all.rs | 2 +- tokio-fs/src/hard_link.rs | 2 +- tokio-fs/src/os/unix.rs | 2 +- tokio-fs/src/os/windows/symlink_dir.rs | 2 +- tokio-fs/src/os/windows/symlink_file.rs | 2 +- tokio-fs/src/read_dir.rs | 2 +- tokio-fs/src/read_link.rs | 2 +- tokio-fs/src/remove_dir.rs | 2 +- tokio-fs/src/remove_file.rs | 2 +- tokio-fs/src/rename.rs | 2 +- tokio-fs/src/set_permissions.rs | 5 +---- tokio-reactor/src/lib.rs | 2 +- tokio-signal/src/unix.rs | 8 ++------ tokio-sync/src/watch.rs | 2 +- tokio-tcp/src/stream.rs | 2 +- tokio-threadpool/src/task/blocking.rs | 2 +- tokio-timer/src/throttle.rs | 2 +- tokio-udp/src/socket.rs | 2 +- tokio/benches/tcp.rs | 4 ++-- tokio/examples/echo-udp.rs | 2 +- 26 files changed, 33 insertions(+), 43 deletions(-) diff --git a/tokio-codec/src/framed.rs b/tokio-codec/src/framed.rs index 26e3373f6..00e477578 100644 --- a/tokio-codec/src/framed.rs +++ b/tokio-codec/src/framed.rs @@ -144,8 +144,8 @@ impl Framed { FramedParts { io: inner.0, codec: inner.1, - read_buf: read_buf, - write_buf: write_buf, + read_buf, + write_buf, _priv: (), } } diff --git a/tokio-codec/src/framed_read.rs b/tokio-codec/src/framed_read.rs index 66bc0df14..163a59bac 100644 --- a/tokio-codec/src/framed_read.rs +++ b/tokio-codec/src/framed_read.rs @@ -138,7 +138,7 @@ where pub fn framed_read2(inner: T) -> FramedRead2 { FramedRead2 { - inner: inner, + inner, eof: false, is_readable: false, buffer: BytesMut::with_capacity(INITIAL_CAPACITY), @@ -151,7 +151,7 @@ pub fn framed_read2_with_buffer(inner: T, mut buf: BytesMut) -> FramedRead2 0, buffer: buf, diff --git a/tokio-codec/src/framed_write.rs b/tokio-codec/src/framed_write.rs index 58bafa963..c150847be 100644 --- a/tokio-codec/src/framed_write.rs +++ b/tokio-codec/src/framed_write.rs @@ -138,7 +138,7 @@ where pub fn framed_write2(inner: T) -> FramedWrite2 { FramedWrite2 { - inner: inner, + inner, buffer: BytesMut::with_capacity(INITIAL_CAPACITY), } } @@ -148,10 +148,7 @@ pub fn framed_write2_with_buffer(inner: T, mut buf: BytesMut) -> FramedWrite2 let bytes_to_reserve = INITIAL_CAPACITY - buf.capacity(); buf.reserve(bytes_to_reserve); } - FramedWrite2 { - inner: inner, - buffer: buf, - } + FramedWrite2 { inner, buffer: buf } } impl FramedWrite2 { diff --git a/tokio-current-thread/src/lib.rs b/tokio-current-thread/src/lib.rs index d540ccc39..21283e93f 100644 --- a/tokio-current-thread/src/lib.rs +++ b/tokio-current-thread/src/lib.rs @@ -268,7 +268,7 @@ impl CurrentThread

{ let num_futures = Arc::new(atomic::AtomicUsize::new(0)); CurrentThread { - scheduler: scheduler, + scheduler, num_futures: num_futures.clone(), park, id, @@ -279,7 +279,7 @@ impl CurrentThread

{ thread, id, }, - spawn_receiver: spawn_receiver, + spawn_receiver, } } diff --git a/tokio-current-thread/src/scheduler.rs b/tokio-current-thread/src/scheduler.rs index c689d7219..481e62985 100644 --- a/tokio-current-thread/src/scheduler.rs +++ b/tokio-current-thread/src/scheduler.rs @@ -147,11 +147,11 @@ where tick_num: AtomicUsize::new(0), head_readiness: AtomicPtr::new(stub_ptr as *mut _), tail_readiness: UnsafeCell::new(stub_ptr), - stub: stub, + stub, }); Scheduler { - inner: inner, + inner, nodes: List::new(), } } diff --git a/tokio-fs/src/create_dir.rs b/tokio-fs/src/create_dir.rs index f691a2b9a..9f245dc41 100644 --- a/tokio-fs/src/create_dir.rs +++ b/tokio-fs/src/create_dir.rs @@ -30,7 +30,7 @@ where P: AsRef, { fn new(path: P) -> CreateDirFuture

{ - CreateDirFuture { path: path } + CreateDirFuture { path } } } diff --git a/tokio-fs/src/create_dir_all.rs b/tokio-fs/src/create_dir_all.rs index d9a84eb25..37e675bee 100644 --- a/tokio-fs/src/create_dir_all.rs +++ b/tokio-fs/src/create_dir_all.rs @@ -31,7 +31,7 @@ where P: AsRef, { fn new(path: P) -> CreateDirAllFuture

{ - CreateDirAllFuture { path: path } + CreateDirAllFuture { path } } } diff --git a/tokio-fs/src/hard_link.rs b/tokio-fs/src/hard_link.rs index e18bac174..39ee90b59 100644 --- a/tokio-fs/src/hard_link.rs +++ b/tokio-fs/src/hard_link.rs @@ -36,7 +36,7 @@ where Q: AsRef, { fn new(src: P, dst: Q) -> HardLinkFuture { - HardLinkFuture { src: src, dst: dst } + HardLinkFuture { src, dst } } } diff --git a/tokio-fs/src/os/unix.rs b/tokio-fs/src/os/unix.rs index b6f8e0be0..e8e222f27 100644 --- a/tokio-fs/src/os/unix.rs +++ b/tokio-fs/src/os/unix.rs @@ -36,7 +36,7 @@ where Q: AsRef, { fn new(src: P, dst: Q) -> SymlinkFuture { - SymlinkFuture { src: src, dst: dst } + SymlinkFuture { src, dst } } } diff --git a/tokio-fs/src/os/windows/symlink_dir.rs b/tokio-fs/src/os/windows/symlink_dir.rs index e322deb99..a9181396f 100644 --- a/tokio-fs/src/os/windows/symlink_dir.rs +++ b/tokio-fs/src/os/windows/symlink_dir.rs @@ -35,7 +35,7 @@ where Q: AsRef, { fn new(src: P, dst: Q) -> SymlinkDirFuture { - SymlinkDirFuture { src: src, dst: dst } + SymlinkDirFuture { src, dst } } } diff --git a/tokio-fs/src/os/windows/symlink_file.rs b/tokio-fs/src/os/windows/symlink_file.rs index afd6b2297..42d1563a5 100644 --- a/tokio-fs/src/os/windows/symlink_file.rs +++ b/tokio-fs/src/os/windows/symlink_file.rs @@ -35,7 +35,7 @@ where Q: AsRef, { fn new(src: P, dst: Q) -> SymlinkFileFuture { - SymlinkFileFuture { src: src, dst: dst } + SymlinkFileFuture { src, dst } } } diff --git a/tokio-fs/src/read_dir.rs b/tokio-fs/src/read_dir.rs index 9585518b0..cf93903e5 100644 --- a/tokio-fs/src/read_dir.rs +++ b/tokio-fs/src/read_dir.rs @@ -37,7 +37,7 @@ where P: AsRef + Send + 'static, { fn new(path: P) -> ReadDirFuture

{ - ReadDirFuture { path: path } + ReadDirFuture { path } } } diff --git a/tokio-fs/src/read_link.rs b/tokio-fs/src/read_link.rs index 980f922eb..3898267f4 100644 --- a/tokio-fs/src/read_link.rs +++ b/tokio-fs/src/read_link.rs @@ -30,7 +30,7 @@ where P: AsRef, { fn new(path: P) -> ReadLinkFuture

{ - ReadLinkFuture { path: path } + ReadLinkFuture { path } } } diff --git a/tokio-fs/src/remove_dir.rs b/tokio-fs/src/remove_dir.rs index 3e666c681..0281ba918 100644 --- a/tokio-fs/src/remove_dir.rs +++ b/tokio-fs/src/remove_dir.rs @@ -30,7 +30,7 @@ where P: AsRef, { fn new(path: P) -> RemoveDirFuture

{ - RemoveDirFuture { path: path } + RemoveDirFuture { path } } } diff --git a/tokio-fs/src/remove_file.rs b/tokio-fs/src/remove_file.rs index b09eae77d..9eaa79298 100644 --- a/tokio-fs/src/remove_file.rs +++ b/tokio-fs/src/remove_file.rs @@ -34,7 +34,7 @@ where P: AsRef, { fn new(path: P) -> RemoveFileFuture

{ - RemoveFileFuture { path: path } + RemoveFileFuture { path } } } diff --git a/tokio-fs/src/rename.rs b/tokio-fs/src/rename.rs index 670a9c7d5..e766a826d 100644 --- a/tokio-fs/src/rename.rs +++ b/tokio-fs/src/rename.rs @@ -36,7 +36,7 @@ where Q: AsRef, { fn new(from: P, to: Q) -> RenameFuture { - RenameFuture { from: from, to: to } + RenameFuture { from, to } } } diff --git a/tokio-fs/src/set_permissions.rs b/tokio-fs/src/set_permissions.rs index e91c33b88..fb8e97a35 100644 --- a/tokio-fs/src/set_permissions.rs +++ b/tokio-fs/src/set_permissions.rs @@ -31,10 +31,7 @@ where P: AsRef, { fn new(path: P, perm: fs::Permissions) -> SetPermissionsFuture

{ - SetPermissionsFuture { - path: path, - perm: perm, - } + SetPermissionsFuture { path, perm } } } diff --git a/tokio-reactor/src/lib.rs b/tokio-reactor/src/lib.rs index 02738c293..29db1faaa 100644 --- a/tokio-reactor/src/lib.rs +++ b/tokio-reactor/src/lib.rs @@ -224,7 +224,7 @@ impl Reactor { events: mio::Events::with_capacity(1024), _wakeup_registration: wakeup_pair.0, inner: Arc::new(Inner { - io: io, + io, next_aba_guard: AtomicUsize::new(0), io_dispatch: RwLock::new(Slab::with_capacity(1)), wakeup: wakeup_pair.1, diff --git a/tokio-signal/src/unix.rs b/tokio-signal/src/unix.rs index fe54d39c6..5e2d3c234 100644 --- a/tokio-signal/src/unix.rs +++ b/tokio-signal/src/unix.rs @@ -195,7 +195,7 @@ impl Driver { let stream = globals().receiver.try_clone()?; let wakeup = PollEvented::new_with_handle(stream, handle)?; - Ok(Driver { wakeup: wakeup }) + Ok(Driver { wakeup }) } /// Drain all data in the global receiver, ensuring we'll get woken up when @@ -321,11 +321,7 @@ impl Signal { let (tx, rx) = channel(1); globals().register_listener(signal as EventId, tx); - Ok(Signal { - driver: driver, - rx: rx, - signal: signal, - }) + Ok(Signal { driver, rx, signal }) }) .boxed() } diff --git a/tokio-sync/src/watch.rs b/tokio-sync/src/watch.rs index 86d4580a2..2e90154d5 100644 --- a/tokio-sync/src/watch.rs +++ b/tokio-sync/src/watch.rs @@ -304,7 +304,7 @@ impl Clone for Receiver { let ver = self.ver; Receiver { - shared: shared, + shared, inner, id, ver, diff --git a/tokio-tcp/src/stream.rs b/tokio-tcp/src/stream.rs index 1c5d63d7a..bf7dfe2e1 100644 --- a/tokio-tcp/src/stream.rs +++ b/tokio-tcp/src/stream.rs @@ -154,7 +154,7 @@ impl TcpStream { Err(e) => Error(e), }; - ConnectFuture { inner: inner } + ConnectFuture { inner } } /// Check the TCP stream's read readiness state. diff --git a/tokio-threadpool/src/task/blocking.rs b/tokio-threadpool/src/task/blocking.rs index 75d41cd63..feb8e187d 100644 --- a/tokio-threadpool/src/task/blocking.rs +++ b/tokio-threadpool/src/task/blocking.rs @@ -100,7 +100,7 @@ impl Blocking { Blocking { state: AtomicUsize::new(init.into()), tail: UnsafeCell::new(ptr), - stub: stub, + stub, lock: AtomicUsize::new(0), } } diff --git a/tokio-timer/src/throttle.rs b/tokio-timer/src/throttle.rs index dae09320f..7f554409e 100644 --- a/tokio-timer/src/throttle.rs +++ b/tokio-timer/src/throttle.rs @@ -27,7 +27,7 @@ impl Throttle { Self { delay: Delay::new_timeout(clock::now() + duration, duration), has_delayed: true, - stream: stream, + stream, } } } diff --git a/tokio-udp/src/socket.rs b/tokio-udp/src/socket.rs index 6cbec5f8c..215836423 100644 --- a/tokio-udp/src/socket.rs +++ b/tokio-udp/src/socket.rs @@ -24,7 +24,7 @@ impl UdpSocket { fn new(socket: mio::net::UdpSocket) -> UdpSocket { let io = PollEvented::new(socket); - UdpSocket { io: io } + UdpSocket { io } } /// Creates a new `UdpSocket` from the previously bound socket provided. diff --git a/tokio/benches/tcp.rs b/tokio/benches/tcp.rs index 124be3695..627d26be9 100644 --- a/tokio/benches/tcp.rs +++ b/tokio/benches/tcp.rs @@ -215,7 +215,7 @@ mod transfer { .and_then(|sock| { sock.set_linger(Some(Duration::from_secs(0))).unwrap(); let drain = Drain { - sock: sock, + sock, chunk: read_size, }; drain @@ -226,7 +226,7 @@ mod transfer { let client = TcpStream::connect(&addr) .and_then(move |sock| Transfer { - sock: sock, + sock, rem: MB, chunk: write_size, }) diff --git a/tokio/examples/echo-udp.rs b/tokio/examples/echo-udp.rs index 54bddb30e..58a73335f 100644 --- a/tokio/examples/echo-udp.rs +++ b/tokio/examples/echo-udp.rs @@ -58,7 +58,7 @@ async fn main() { println!("Listening on: {}", socket.local_addr().unwrap()); let server = Server { - socket: socket, + socket, buf: vec![0; 1024], to_send: None, };