summary refs log tree commit diff
path: root/devices/src
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-15 15:56:35 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-18 19:51:01 -0700
commit64cd5eae5778b86f6e498a6fa1b1962693aa5a46 (patch)
tree9b68f7fce3385c410f4fd9c4e978660a9b5a0973 /devices/src
parentb1de6323ab8c96c52a60e0ff735e4bbb8a8464c9 (diff)
downloadcrosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.gz
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.bz2
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.lz
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.xz
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.tar.zst
crosvm-64cd5eae5778b86f6e498a6fa1b1962693aa5a46.zip
edition: Eliminate ref keyword
As described in:
https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html
which also covers the new mental model that the Rust Book will use for
teaching binding modes and has been found to be more friendly for both
beginners and experienced users.

Before:

    match *opt {
        Some(ref v) => ...,
        None => ...,
    }

After:

    match opt {
        Some(v) => ...,
        None => ...,
    }

TEST=cargo check --all-features
TEST=local kokoro

Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7
Reviewed-on: https://chromium-review.googlesource.com/1566669
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Diffstat (limited to 'devices/src')
-rw-r--r--devices/src/pit.rs6
-rw-r--r--devices/src/usb/host_backend/host_backend_device_provider.rs4
-rw-r--r--devices/src/usb/host_backend/host_device.rs2
-rw-r--r--devices/src/usb/xhci/device_slot.rs4
-rw-r--r--devices/src/usb/xhci/xhci_controller.rs6
-rw-r--r--devices/src/utils/event_loop.rs8
-rw-r--r--devices/src/virtio/block.rs4
-rw-r--r--devices/src/virtio/gpu/backend.rs10
-rw-r--r--devices/src/virtio/gpu/mod.rs6
-rw-r--r--devices/src/virtio/gpu/protocol.rs84
-rw-r--r--devices/src/virtio/input/mod.rs2
-rw-r--r--devices/src/virtio/net.rs4
-rw-r--r--devices/src/virtio/rng.rs2
-rw-r--r--devices/src/virtio/vhost/net.rs8
-rw-r--r--devices/src/virtio/vhost/vsock.rs8
-rw-r--r--devices/src/virtio/vhost/worker.rs2
-rw-r--r--devices/src/virtio/virtio_pci_device.rs4
-rw-r--r--devices/src/virtio/wl.rs36
18 files changed, 99 insertions, 101 deletions
diff --git a/devices/src/pit.rs b/devices/src/pit.rs
index 0bcf0a6..63f31f5 100644
--- a/devices/src/pit.rs
+++ b/devices/src/pit.rs
@@ -669,7 +669,7 @@ impl PitCounter {
         // For square wave mode, this isn't quite accurate to the spec, but the
         // difference isn't meaningfully visible to the guest in any important way,
         // and the code is simpler without the special case.
-        if let Some(ref mut interrupt) = self.interrupt_evt {
+        if let Some(interrupt) = &mut self.interrupt_evt {
             // This is safe because the file descriptor is nonblocking and we're writing 1.
             interrupt.write(1).unwrap();
         }
@@ -686,9 +686,9 @@ impl PitCounter {
     }
 
     fn get_ticks_passed(&self) -> u64 {
-        match self.start {
+        match &self.start {
             None => 0,
-            Some(ref t) => {
+            Some(t) => {
                 let dur = self.clock.lock().now().duration_since(t);
                 let dur_ns: u64 = dur.as_secs() * NANOS_PER_SEC + u64::from(dur.subsec_nanos());
                 (dur_ns * FREQUENCY_HZ / NANOS_PER_SEC)
diff --git a/devices/src/usb/host_backend/host_backend_device_provider.rs b/devices/src/usb/host_backend/host_backend_device_provider.rs
index beae028..6a68951 100644
--- a/devices/src/usb/host_backend/host_backend_device_provider.rs
+++ b/devices/src/usb/host_backend/host_backend_device_provider.rs
@@ -290,8 +290,8 @@ impl ProviderInner {
             UsbControlCommand::ListDevice { port } => {
                 let port_number = port;
                 let result = match self.usb_hub.get_port(port_number) {
-                    Some(port) => match *port.get_backend_device() {
-                        Some(ref device) => {
+                    Some(port) => match port.get_backend_device().as_ref() {
+                        Some(device) => {
                             let vid = device.get_vid();
                             let pid = device.get_pid();
                             UsbControlResult::Device {
diff --git a/devices/src/usb/host_backend/host_device.rs b/devices/src/usb/host_backend/host_device.rs
index cb4097e..b7ca0d1 100644
--- a/devices/src/usb/host_backend/host_device.rs
+++ b/devices/src/usb/host_backend/host_device.rs
@@ -299,7 +299,7 @@ impl HostDevice {
                                 }
                                 XhciTransferState::Completed => {
                                     let status = t.status();
-                                    if let Some(ref buffer) = buffer {
+                                    if let Some(buffer) = &buffer {
                                         let _bytes = buffer
                                             .write(&t.buffer().data_buffer)
                                             .map_err(Error::WriteBuffer)?
diff --git a/devices/src/usb/xhci/device_slot.rs b/devices/src/usb/xhci/device_slot.rs
index 5f82d4a..ef58edb 100644
--- a/devices/src/usb/xhci/device_slot.rs
+++ b/devices/src/usb/xhci/device_slot.rs
@@ -430,8 +430,8 @@ impl DeviceSlot {
                 .set_state(DeviceSlotState::Default);
         } else {
             let port = self.hub.get_port(port_id).ok_or(Error::GetPort(port_id))?;
-            match *port.get_backend_device() {
-                Some(ref mut backend) => {
+            match port.get_backend_device().as_mut() {
+                Some(backend) => {
                     backend.set_address(self.slot_id as u32);
                 }
                 None => {
diff --git a/devices/src/usb/xhci/xhci_controller.rs b/devices/src/usb/xhci/xhci_controller.rs
index 03f2cfc..1f58a5d 100644
--- a/devices/src/usb/xhci/xhci_controller.rs
+++ b/devices/src/usb/xhci/xhci_controller.rs
@@ -168,10 +168,8 @@ impl PciDevice for XhciController {
     }
 
     fn keep_fds(&self) -> Vec<RawFd> {
-        match self.state {
-            XhciControllerState::Created {
-                ref device_provider,
-            } => device_provider.keep_fds(),
+        match &self.state {
+            XhciControllerState::Created { device_provider } => device_provider.keep_fds(),
             _ => {
                 error!("xhci controller is in a wrong state");
                 vec![]
diff --git a/devices/src/utils/event_loop.rs b/devices/src/utils/event_loop.rs
index d91aec9..2abcfda 100644
--- a/devices/src/utils/event_loop.rs
+++ b/devices/src/utils/event_loop.rs
@@ -21,15 +21,15 @@ pub trait FailHandle: Send + Sync {
 
 impl FailHandle for Option<Arc<dyn FailHandle>> {
     fn fail(&self) {
-        match *self {
-            Some(ref handle) => handle.fail(),
+        match self {
+            Some(handle) => handle.fail(),
             None => error!("event loop trying to fail without a fail handle"),
         }
     }
 
     fn failed(&self) -> bool {
-        match &self {
-            Some(ref handle) => handle.failed(),
+        match self {
+            Some(handle) => handle.failed(),
             None => false,
         }
     }
diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs
index 8c403a6..bcf0cf1 100644
--- a/devices/src/virtio/block.rs
+++ b/devices/src/virtio/block.rs
@@ -890,11 +890,11 @@ impl<T: 'static + AsRawFd + DiskFile + Send> VirtioDevice for Block<T> {
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
 
-        if let Some(ref disk_image) = self.disk_image {
+        if let Some(disk_image) = &self.disk_image {
             keep_fds.push(disk_image.as_raw_fd());
         }
 
-        if let Some(ref control_socket) = self.control_socket {
+        if let Some(control_socket) = &self.control_socket {
             keep_fds.push(control_socket.as_raw_fd());
         }
 
diff --git a/devices/src/virtio/gpu/backend.rs b/devices/src/virtio/gpu/backend.rs
index 0359dd3..2de357f 100644
--- a/devices/src/virtio/gpu/backend.rs
+++ b/devices/src/virtio/gpu/backend.rs
@@ -208,7 +208,7 @@ impl VirglResource for BackedBuffer {
 
     fn attach_guest_backing(&mut self, mem: &GuestMemory, vecs: Vec<(GuestAddress, usize)>) {
         self.backing = vecs.clone();
-        if let Some(ref mut resource) = self.gpu_renderer_resource {
+        if let Some(resource) = &mut self.gpu_renderer_resource {
             if let Err(e) = resource.attach_backing(&vecs[..], mem) {
                 error!("failed to attach backing to BackBuffer resource: {}", e);
             }
@@ -216,7 +216,7 @@ impl VirglResource for BackedBuffer {
     }
 
     fn detach_guest_backing(&mut self) {
-        if let Some(ref mut resource) = self.gpu_renderer_resource {
+        if let Some(resource) = &mut self.gpu_renderer_resource {
             resource.detach_backing();
         }
         self.backing.clear();
@@ -231,9 +231,9 @@ impl VirglResource for BackedBuffer {
     }
 
     fn import_to_display(&mut self, display: &Rc<RefCell<GpuDisplay>>) -> Option<u32> {
-        if let Some((ref self_display, import)) = self.display_import {
-            if Rc::ptr_eq(&self_display, display) {
-                return Some(import);
+        if let Some((self_display, import)) = &self.display_import {
+            if Rc::ptr_eq(self_display, display) {
+                return Some(*import);
             }
         }
         let dmabuf = match self.buffer.export_plane_fd(0) {
diff --git a/devices/src/virtio/gpu/mod.rs b/devices/src/virtio/gpu/mod.rs
index 2c13acc..e8fb49f 100644
--- a/devices/src/virtio/gpu/mod.rs
+++ b/devices/src/virtio/gpu/mod.rs
@@ -515,7 +515,7 @@ impl Worker {
             }
         };
 
-        if let Some(ref resource_bridge) = self.resource_bridge {
+        if let Some(resource_bridge) = &self.resource_bridge {
             if let Err(e) = poll_ctx.add(resource_bridge, Token::ResourceBridge) {
                 error!("failed to add resource bridge to PollContext: {}", e);
             }
@@ -586,7 +586,7 @@ impl Worker {
             // created or destroyed by the control queue. Processing the resource bridge first may
             // lead to a race condition.
             if process_resource_bridge {
-                if let Some(ref resource_bridge) = self.resource_bridge {
+                if let Some(resource_bridge) = &self.resource_bridge {
                     self.state.process_resource_bridge(resource_bridge);
                 }
             }
@@ -654,7 +654,7 @@ impl VirtioDevice for Gpu {
             keep_fds.push(libc::STDERR_FILENO);
         }
         keep_fds.push(self.exit_evt.as_raw_fd());
-        if let Some(ref resource_bridge) = self.resource_bridge {
+        if let Some(resource_bridge) = &self.resource_bridge {
             keep_fds.push(resource_bridge.as_raw_fd());
         }
         keep_fds
diff --git a/devices/src/virtio/gpu/protocol.rs b/devices/src/virtio/gpu/protocol.rs
index f0dcad8..033f799 100644
--- a/devices/src/virtio/gpu/protocol.rs
+++ b/devices/src/virtio/gpu/protocol.rs
@@ -517,27 +517,27 @@ impl From<VolatileMemoryError> for GpuCommandDecodeError {
 impl fmt::Debug for GpuCommand {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         use self::GpuCommand::*;
-        match *self {
-            GetDisplayInfo(ref _info) => f.debug_struct("GetDisplayInfo").finish(),
-            ResourceCreate2d(ref _info) => f.debug_struct("ResourceCreate2d").finish(),
-            ResourceUnref(ref _info) => f.debug_struct("ResourceUnref").finish(),
-            SetScanout(ref _info) => f.debug_struct("SetScanout").finish(),
-            ResourceFlush(ref _info) => f.debug_struct("ResourceFlush").finish(),
-            TransferToHost2d(ref _info) => f.debug_struct("TransferToHost2d").finish(),
-            ResourceAttachBacking(ref _info) => f.debug_struct("ResourceAttachBacking").finish(),
-            ResourceDetachBacking(ref _info) => f.debug_struct("ResourceDetachBacking").finish(),
-            GetCapsetInfo(ref _info) => f.debug_struct("GetCapsetInfo").finish(),
-            GetCapset(ref _info) => f.debug_struct("GetCapset").finish(),
-            CtxCreate(ref _info) => f.debug_struct("CtxCreate").finish(),
-            CtxDestroy(ref _info) => f.debug_struct("CtxDestroy").finish(),
-            CtxAttachResource(ref _info) => f.debug_struct("CtxAttachResource").finish(),
-            CtxDetachResource(ref _info) => f.debug_struct("CtxDetachResource").finish(),
-            ResourceCreate3d(ref _info) => f.debug_struct("ResourceCreate3d").finish(),
-            TransferToHost3d(ref _info) => f.debug_struct("TransferToHost3d").finish(),
-            TransferFromHost3d(ref _info) => f.debug_struct("TransferFromHost3d").finish(),
-            CmdSubmit3d(ref _info) => f.debug_struct("CmdSubmit3d").finish(),
-            UpdateCursor(ref _info) => f.debug_struct("UpdateCursor").finish(),
-            MoveCursor(ref _info) => f.debug_struct("MoveCursor").finish(),
+        match self {
+            GetDisplayInfo(_info) => f.debug_struct("GetDisplayInfo").finish(),
+            ResourceCreate2d(_info) => f.debug_struct("ResourceCreate2d").finish(),
+            ResourceUnref(_info) => f.debug_struct("ResourceUnref").finish(),
+            SetScanout(_info) => f.debug_struct("SetScanout").finish(),
+            ResourceFlush(_info) => f.debug_struct("ResourceFlush").finish(),
+            TransferToHost2d(_info) => f.debug_struct("TransferToHost2d").finish(),
+            ResourceAttachBacking(_info) => f.debug_struct("ResourceAttachBacking").finish(),
+            ResourceDetachBacking(_info) => f.debug_struct("ResourceDetachBacking").finish(),
+            GetCapsetInfo(_info) => f.debug_struct("GetCapsetInfo").finish(),
+            GetCapset(_info) => f.debug_struct("GetCapset").finish(),
+            CtxCreate(_info) => f.debug_struct("CtxCreate").finish(),
+            CtxDestroy(_info) => f.debug_struct("CtxDestroy").finish(),
+            CtxAttachResource(_info) => f.debug_struct("CtxAttachResource").finish(),
+            CtxDetachResource(_info) => f.debug_struct("CtxDetachResource").finish(),
+            ResourceCreate3d(_info) => f.debug_struct("ResourceCreate3d").finish(),
+            TransferToHost3d(_info) => f.debug_struct("TransferToHost3d").finish(),
+            TransferFromHost3d(_info) => f.debug_struct("TransferFromHost3d").finish(),
+            CmdSubmit3d(_info) => f.debug_struct("CmdSubmit3d").finish(),
+            UpdateCursor(_info) => f.debug_struct("UpdateCursor").finish(),
+            MoveCursor(_info) => f.debug_struct("MoveCursor").finish(),
         }
     }
 }
@@ -575,27 +575,27 @@ impl GpuCommand {
     /// Gets the generic `virtio_gpu_ctrl_hdr` from this command.
     pub fn ctrl_hdr(&self) -> &virtio_gpu_ctrl_hdr {
         use self::GpuCommand::*;
-        match *self {
-            GetDisplayInfo(ref info) => &info,
-            ResourceCreate2d(ref info) => &info.hdr,
-            ResourceUnref(ref info) => &info.hdr,
-            SetScanout(ref info) => &info.hdr,
-            ResourceFlush(ref info) => &info.hdr,
-            TransferToHost2d(ref info) => &info.hdr,
-            ResourceAttachBacking(ref info) => &info.hdr,
-            ResourceDetachBacking(ref info) => &info.hdr,
-            GetCapsetInfo(ref info) => &info.hdr,
-            GetCapset(ref info) => &info.hdr,
-            CtxCreate(ref info) => &info.hdr,
-            CtxDestroy(ref info) => &info.hdr,
-            CtxAttachResource(ref info) => &info.hdr,
-            CtxDetachResource(ref info) => &info.hdr,
-            ResourceCreate3d(ref info) => &info.hdr,
-            TransferToHost3d(ref info) => &info.hdr,
-            TransferFromHost3d(ref info) => &info.hdr,
-            CmdSubmit3d(ref info) => &info.hdr,
-            UpdateCursor(ref info) => &info.hdr,
-            MoveCursor(ref info) => &info.hdr,
+        match self {
+            GetDisplayInfo(info) => info,
+            ResourceCreate2d(info) => &info.hdr,
+            ResourceUnref(info) => &info.hdr,
+            SetScanout(info) => &info.hdr,
+            ResourceFlush(info) => &info.hdr,
+            TransferToHost2d(info) => &info.hdr,
+            ResourceAttachBacking(info) => &info.hdr,
+            ResourceDetachBacking(info) => &info.hdr,
+            GetCapsetInfo(info) => &info.hdr,
+            GetCapset(info) => &info.hdr,
+            CtxCreate(info) => &info.hdr,
+            CtxDestroy(info) => &info.hdr,
+            CtxAttachResource(info) => &info.hdr,
+            CtxDetachResource(info) => &info.hdr,
+            ResourceCreate3d(info) => &info.hdr,
+            TransferToHost3d(info) => &info.hdr,
+            TransferFromHost3d(info) => &info.hdr,
+            CmdSubmit3d(info) => &info.hdr,
+            UpdateCursor(info) => &info.hdr,
+            MoveCursor(info) => &info.hdr,
         }
     }
 }
diff --git a/devices/src/virtio/input/mod.rs b/devices/src/virtio/input/mod.rs
index 5a751e2..9aa60b2 100644
--- a/devices/src/virtio/input/mod.rs
+++ b/devices/src/virtio/input/mod.rs
@@ -597,7 +597,7 @@ where
     T: 'static + EventSource + Send,
 {
     fn keep_fds(&self) -> Vec<RawFd> {
-        if let Some(ref source) = self.source {
+        if let Some(source) = &self.source {
             return vec![source.as_raw_fd()];
         }
         Vec::new()
diff --git a/devices/src/virtio/net.rs b/devices/src/virtio/net.rs
index a492561..d7de639 100644
--- a/devices/src/virtio/net.rs
+++ b/devices/src/virtio/net.rs
@@ -435,11 +435,11 @@ where
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
 
-        if let Some(ref tap) = self.tap {
+        if let Some(tap) = &self.tap {
             keep_fds.push(tap.as_raw_fd());
         }
 
-        if let Some(ref workers_kill_evt) = self.workers_kill_evt {
+        if let Some(workers_kill_evt) = &self.workers_kill_evt {
             keep_fds.push(workers_kill_evt.as_raw_fd());
         }
 
diff --git a/devices/src/virtio/rng.rs b/devices/src/virtio/rng.rs
index b8e49f7..8dda4c7 100644
--- a/devices/src/virtio/rng.rs
+++ b/devices/src/virtio/rng.rs
@@ -173,7 +173,7 @@ impl VirtioDevice for Rng {
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
 
-        if let Some(ref random_file) = self.random_file {
+        if let Some(random_file) = &self.random_file {
             keep_fds.push(random_file.as_raw_fd());
         }
 
diff --git a/devices/src/virtio/vhost/net.rs b/devices/src/virtio/vhost/net.rs
index d2e7e55..a7eaf18 100644
--- a/devices/src/virtio/vhost/net.rs
+++ b/devices/src/virtio/vhost/net.rs
@@ -115,19 +115,19 @@ where
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
 
-        if let Some(ref tap) = self.tap {
+        if let Some(tap) = &self.tap {
             keep_fds.push(tap.as_raw_fd());
         }
 
-        if let Some(ref vhost_net_handle) = self.vhost_net_handle {
+        if let Some(vhost_net_handle) = &self.vhost_net_handle {
             keep_fds.push(vhost_net_handle.as_raw_fd());
         }
 
-        if let Some(ref vhost_interrupt) = self.vhost_interrupt {
+        if let Some(vhost_interrupt) = &self.vhost_interrupt {
             keep_fds.push(vhost_interrupt.as_raw_fd());
         }
 
-        if let Some(ref workers_kill_evt) = self.workers_kill_evt {
+        if let Some(workers_kill_evt) = &self.workers_kill_evt {
             keep_fds.push(workers_kill_evt.as_raw_fd());
         }
 
diff --git a/devices/src/virtio/vhost/vsock.rs b/devices/src/virtio/vhost/vsock.rs
index 7f4c457..d07b639 100644
--- a/devices/src/virtio/vhost/vsock.rs
+++ b/devices/src/virtio/vhost/vsock.rs
@@ -76,7 +76,7 @@ impl Drop for Vsock {
     fn drop(&mut self) {
         // Only kill the child if it claimed its eventfd.
         if self.worker_kill_evt.is_none() {
-            if let Some(ref kill_evt) = self.kill_evt {
+            if let Some(kill_evt) = &self.kill_evt {
                 // Ignore the result because there is nothing we can do about it.
                 let _ = kill_evt.write(1);
             }
@@ -88,15 +88,15 @@ impl VirtioDevice for Vsock {
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
 
-        if let Some(ref handle) = self.vhost_handle {
+        if let Some(handle) = &self.vhost_handle {
             keep_fds.push(handle.as_raw_fd());
         }
 
-        if let Some(ref interrupt) = self.interrupt {
+        if let Some(interrupt) = &self.interrupt {
             keep_fds.push(interrupt.as_raw_fd());
         }
 
-        if let Some(ref worker_kill_evt) = self.worker_kill_evt {
+        if let Some(worker_kill_evt) = &self.worker_kill_evt {
             keep_fds.push(worker_kill_evt.as_raw_fd());
         }
 
diff --git a/devices/src/virtio/vhost/worker.rs b/devices/src/virtio/vhost/worker.rs
index 88ad7e3..9389f82 100644
--- a/devices/src/virtio/vhost/worker.rs
+++ b/devices/src/virtio/vhost/worker.rs
@@ -82,7 +82,7 @@ impl<T: Vhost> Worker<T> {
             .set_mem_table()
             .map_err(Error::VhostSetMemTable)?;
 
-        for (queue_index, ref queue) in self.queues.iter().enumerate() {
+        for (queue_index, queue) in self.queues.iter().enumerate() {
             self.vhost_handle
                 .set_vring_num(queue_index, queue.max_size)
                 .map_err(Error::VhostSetVringNum)?;
diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs
index 725beda..337b7bb 100644
--- a/devices/src/virtio/virtio_pci_device.rs
+++ b/devices/src/virtio/virtio_pci_device.rs
@@ -302,10 +302,10 @@ impl PciDevice for VirtioPciDevice {
 
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut fds = self.device.keep_fds();
-        if let Some(ref interrupt_evt) = self.interrupt_evt {
+        if let Some(interrupt_evt) = &self.interrupt_evt {
             fds.push(interrupt_evt.as_raw_fd());
         }
-        if let Some(ref interrupt_resample_evt) = self.interrupt_resample_evt {
+        if let Some(interrupt_resample_evt) = &self.interrupt_resample_evt {
             fds.push(interrupt_resample_evt.as_raw_fd());
         }
         fds
diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs
index 08890b0..3bc9c07 100644
--- a/devices/src/virtio/wl.rs
+++ b/devices/src/virtio/wl.rs
@@ -692,16 +692,16 @@ struct WlVfd {
 impl fmt::Debug for WlVfd {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "WlVfd {{")?;
-        if let Some(ref s) = self.socket {
+        if let Some(s) = &self.socket {
             write!(f, " socket: {}", s.as_raw_fd())?;
         }
-        if let Some(&(slot, pfn, _)) = self.slot.as_ref() {
+        if let Some((slot, pfn, _)) = &self.slot {
             write!(f, " slot: {} pfn: {}", slot, pfn)?;
         }
-        if let Some(ref s) = self.remote_pipe {
+        if let Some(s) = &self.remote_pipe {
             write!(f, " remote: {}", s.as_raw_fd())?;
         }
-        if let Some((_, ref s)) = self.local_pipe {
+        if let Some((_, s)) = &self.local_pipe {
             write!(f, " local: {}", s.as_raw_fd())?;
         }
         write!(f, " }}")
@@ -781,8 +781,8 @@ impl WlVfd {
             return Err(WlError::DmabufSync(io::Error::from_raw_os_error(EINVAL)));
         }
 
-        match self.guest_shared_memory.as_ref() {
-            Some(&(_, ref fd)) => {
+        match &self.guest_shared_memory {
+            Some((_, fd)) => {
                 let sync = dma_buf_sync {
                     flags: flags as u64,
                 };
@@ -885,25 +885,25 @@ impl WlVfd {
     fn send_fd(&self) -> Option<RawFd> {
         self.guest_shared_memory
             .as_ref()
-            .map(|&(_, ref fd)| fd.as_raw_fd())
+            .map(|(_, fd)| fd.as_raw_fd())
             .or(self.socket.as_ref().map(|s| s.as_raw_fd()))
             .or(self.remote_pipe.as_ref().map(|p| p.as_raw_fd()))
     }
 
     // The FD that is used for polling for events on this VFD.
     fn poll_fd(&self) -> Option<&dyn AsRawFd> {
-        self.socket.as_ref().map(|s| s as &dyn AsRawFd).or(self
-            .local_pipe
+        self.socket
             .as_ref()
-            .map(|&(_, ref p)| p as &dyn AsRawFd))
+            .map(|s| s as &dyn AsRawFd)
+            .or(self.local_pipe.as_ref().map(|(_, p)| p as &dyn AsRawFd))
     }
 
     // Sends data/files from the guest to the host over this VFD.
     fn send(&mut self, fds: &[RawFd], data: VolatileSlice) -> WlResult<WlResp> {
-        if let Some(ref socket) = self.socket {
+        if let Some(socket) = &self.socket {
             socket.send_with_fds(data, fds).map_err(WlError::SendVfd)?;
             Ok(WlResp::Ok)
-        } else if let Some((_, ref mut local_pipe)) = self.local_pipe {
+        } else if let Some((_, local_pipe)) = &mut self.local_pipe {
             // Impossible to send fds over a simple pipe.
             if !fds.is_empty() {
                 return Ok(WlResp::InvalidType);
@@ -1187,10 +1187,10 @@ impl WlState {
 
     fn close(&mut self, vfd_id: u32) -> WlResult<WlResp> {
         let mut to_delete = Set::new();
-        for &(dest_vfd_id, ref q) in self.in_queue.iter() {
-            if dest_vfd_id == vfd_id {
-                if let WlRecv::Vfd { id } = *q {
-                    to_delete.insert(id);
+        for (dest_vfd_id, q) in self.in_queue.iter() {
+            if *dest_vfd_id == vfd_id {
+                if let WlRecv::Vfd { id } = q {
+                    to_delete.insert(*id);
                 }
             }
         }
@@ -1710,10 +1710,10 @@ impl VirtioDevice for Wl {
     fn keep_fds(&self) -> Vec<RawFd> {
         let mut keep_fds = Vec::new();
 
-        if let Some(ref vm_socket) = self.vm_socket {
+        if let Some(vm_socket) = &self.vm_socket {
             keep_fds.push(vm_socket.as_raw_fd());
         }
-        if let Some(ref resource_bridge) = self.resource_bridge {
+        if let Some(resource_bridge) = &self.resource_bridge {
             keep_fds.push(resource_bridge.as_raw_fd());
         }