From bc84a1c79bd37c648120ef30768d9b90eee2c4af Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 11 Feb 2021 16:21:45 +0000 Subject: [PATCH] build: Remove nested matches Update for clippy in Rust 1.50.0: error: Unnecessary nested match --> vmm/src/vm.rs:419:17 | 419 | / if let vm_device::BusError::MissingAddressRange = e { 420 | | warn!("Guest MMIO write to unregistered address 0x{:x}", gpa); 421 | | } | |_________________^ | = note: `-D clippy::collapsible-match` implied by `-D warnings` help: The outer pattern can be modified to include the inner pattern. --> vmm/src/vm.rs:418:17 | 418 | Err(e) => { | ^ Replace this binding 419 | if let vm_device::BusError::MissingAddressRange = e { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match Signed-off-by: Rob Bradford --- vmm/src/vm.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 0f3e67487..3b831a714 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -407,20 +407,16 @@ impl VmmOps for VmOps { } fn mmio_read(&self, gpa: u64, data: &mut [u8]) -> hypervisor::vm::Result<()> { - if let Err(e) = self.mmio_bus.read(gpa, data) { - if let vm_device::BusError::MissingAddressRange = e { - warn!("Guest MMIO read to unregistered address 0x{:x}", gpa); - } + if let Err(vm_device::BusError::MissingAddressRange) = self.mmio_bus.read(gpa, data) { + warn!("Guest MMIO read to unregistered address 0x{:x}", gpa); } Ok(()) } fn mmio_write(&self, gpa: u64, data: &[u8]) -> hypervisor::vm::Result<()> { match self.mmio_bus.write(gpa, data) { - Err(e) => { - if let vm_device::BusError::MissingAddressRange = e { - warn!("Guest MMIO write to unregistered address 0x{:x}", gpa); - } + Err(vm_device::BusError::MissingAddressRange) => { + warn!("Guest MMIO write to unregistered address 0x{:x}", gpa); } Ok(Some(barrier)) => { info!("Waiting for barrier"); @@ -434,10 +430,8 @@ impl VmmOps for VmOps { #[cfg(target_arch = "x86_64")] fn pio_read(&self, port: u64, data: &mut [u8]) -> hypervisor::vm::Result<()> { - if let Err(e) = self.io_bus.read(port, data) { - if let vm_device::BusError::MissingAddressRange = e { - warn!("Guest PIO read to unregistered address 0x{:x}", port); - } + if let Err(vm_device::BusError::MissingAddressRange) = self.io_bus.read(port, data) { + warn!("Guest PIO read to unregistered address 0x{:x}", port); } Ok(()) } @@ -450,10 +444,8 @@ impl VmmOps for VmOps { } match self.io_bus.write(port, data) { - Err(e) => { - if let vm_device::BusError::MissingAddressRange = e { - warn!("Guest PIO write to unregistered address 0x{:x}", port); - } + Err(vm_device::BusError::MissingAddressRange) => { + warn!("Guest PIO write to unregistered address 0x{:x}", port); } Ok(Some(barrier)) => { info!("Waiting for barrier");