From 859bce5cae74fada44ae8b4fc8a5b68d4d702e2a Mon Sep 17 00:00:00 2001 From: Tushar Khatri Date: Fri, 12 Jun 2026 16:11:41 +0000 Subject: [PATCH] hypervisor: reevaluate #[allow] attributes Remove stale #[allow]s whose lints no longer fire, convert the unconditionally-firing ones to #[expect], and keep the conditional ones as #[allow] (e.g. large_enum_variant only fires when both kvm and mshv are enabled; a nonminimal_bool only on x86). The many unreachable_patterns allows are feature-gated and left as #[allow]. Part of #8326. Signed-off-by: Tushar Khatri --- hypervisor/src/arch/aarch64/regs.rs | 2 +- hypervisor/src/arch/x86/emulator/instructions/mov.rs | 2 +- hypervisor/src/arch/x86/emulator/instructions/movs.rs | 2 +- hypervisor/src/arch/x86/emulator/instructions/or.rs | 2 +- hypervisor/src/arch/x86/emulator/instructions/stos.rs | 2 +- hypervisor/src/arch/x86/mod.rs | 4 +--- hypervisor/src/kvm/mod.rs | 2 +- hypervisor/src/mshv/mod.rs | 4 ++-- hypervisor/src/mshv/x86_64/emulator.rs | 2 +- 9 files changed, 10 insertions(+), 12 deletions(-) diff --git a/hypervisor/src/arch/aarch64/regs.rs b/hypervisor/src/arch/aarch64/regs.rs index 10e0e49eb..756514ba7 100644 --- a/hypervisor/src/arch/aarch64/regs.rs +++ b/hypervisor/src/arch/aarch64/regs.rs @@ -165,7 +165,7 @@ pub enum ExceptionClass { BRK = 0b111100, } -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] // PSR (Processor State Register) bits. // Taken from arch/arm64/include/uapi/asm/ptrace.h. const PSR_MODE_EL1h: u64 = 0x0000_0005; diff --git a/hypervisor/src/arch/x86/emulator/instructions/mov.rs b/hypervisor/src/arch/x86/emulator/instructions/mov.rs index d5c275392..6b4a5de62 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/mov.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/mov.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] // // MOV-Move diff --git a/hypervisor/src/arch/x86/emulator/instructions/movs.rs b/hypervisor/src/arch/x86/emulator/instructions/movs.rs index 498f637c3..eeecbc466 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/movs.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/movs.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] // // MOVS - Move Data from String to String diff --git a/hypervisor/src/arch/x86/emulator/instructions/or.rs b/hypervisor/src/arch/x86/emulator/instructions/or.rs index 903c64be4..138645f67 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/or.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/or.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] // // OR - Logical inclusive OR diff --git a/hypervisor/src/arch/x86/emulator/instructions/stos.rs b/hypervisor/src/arch/x86/emulator/instructions/stos.rs index a000f117e..84cd843b5 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/stos.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/stos.rs @@ -4,7 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#![allow(non_camel_case_types)] +#![expect(non_camel_case_types)] // // STOS - Store String diff --git a/hypervisor/src/arch/x86/mod.rs b/hypervisor/src/arch/x86/mod.rs index 45f820cde..38c3b5b46 100644 --- a/hypervisor/src/arch/x86/mod.rs +++ b/hypervisor/src/arch/x86/mod.rs @@ -20,9 +20,7 @@ use crate::CpuVendor; #[cfg(all(feature = "mshv_emulator", target_arch = "x86_64"))] pub mod emulator; pub mod gdt; -#[allow(non_camel_case_types)] -#[allow(non_snake_case)] -#[allow(non_upper_case_globals)] +#[expect(non_upper_case_globals)] pub mod msr_index; // MTRR constants diff --git a/hypervisor/src/kvm/mod.rs b/hypervisor/src/kvm/mod.rs index d78470b8b..d031d335a 100644 --- a/hypervisor/src/kvm/mod.rs +++ b/hypervisor/src/kvm/mod.rs @@ -1512,7 +1512,7 @@ pub type KvmResult = result::Result; impl KvmHypervisor { /// Create a hypervisor based on Kvm - #[allow(clippy::new_ret_no_self)] + #[expect(clippy::new_ret_no_self)] pub fn new() -> hypervisor::Result> { let kvm_obj = Kvm::new().map_err(|e| hypervisor::HypervisorError::VmCreate(e.into()))?; let api_version = kvm_obj.get_api_version(); diff --git a/hypervisor/src/mshv/mod.rs b/hypervisor/src/mshv/mod.rs index e2e0f7ac1..858317705 100644 --- a/hypervisor/src/mshv/mod.rs +++ b/hypervisor/src/mshv/mod.rs @@ -233,7 +233,7 @@ pub struct MshvHypervisor { impl MshvHypervisor { /// Create a hypervisor based on Mshv - #[allow(clippy::new_ret_no_self)] + #[expect(clippy::new_ret_no_self)] pub fn new() -> hypervisor::Result> { let mshv_obj = Mshv::new().map_err(|e| hypervisor::HypervisorError::HypervisorCreate(e.into()))?; @@ -586,7 +586,7 @@ impl cpu::Vcpu for MshvVcpu { Ok(()) } - #[allow(non_upper_case_globals)] + #[expect(non_upper_case_globals)] fn run(&mut self) -> std::result::Result { match self.fd.run() { Ok(x) => match x.header.message_type { diff --git a/hypervisor/src/mshv/x86_64/emulator.rs b/hypervisor/src/mshv/x86_64/emulator.rs index ab18e96bb..cc4d77730 100644 --- a/hypervisor/src/mshv/x86_64/emulator.rs +++ b/hypervisor/src/mshv/x86_64/emulator.rs @@ -23,7 +23,7 @@ pub struct MshvEmulatorContext<'a> { impl MshvEmulatorContext<'_> { // Do the actual gva -> gpa translation - #[allow(non_upper_case_globals)] + #[expect(non_upper_case_globals)] fn translate(&self, gva: u64, flags: u32) -> Result { if let Some((cached_gva, cached_gpa)) = self.mapping && cached_gva == gva