hypervisor: Suppress unused_unsafe warning

x86::__cpuid is safe on Rust ≥1.94 but unsafe on older versions.  This
causes unused_unsafe warnings when compiling with Rust ≥1.94.  However,
on earlier Rust versions, the code won’t compile if the unsafe blocks
are absent.

Work around this by adding #[allow(unused_unsafe)] where needed to
suppress the warnings.

See #7588 for more discussion.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
Demi Marie Obenour 2025-12-31 12:06:24 -05:00 committed by Bo Chen
parent f6f0d49c62
commit 2e05836669
2 changed files with 9 additions and 1 deletions

View file

@ -155,7 +155,8 @@ pub trait Hypervisor: Send + Sync {
/// Determine CPU vendor
///
fn get_cpu_vendor(&self) -> CpuVendor {
// SAFETY: call cpuid with valid leaves
#[allow(unused_unsafe)]
// SAFETY: not actually unsafe, but considered unsafe by current stable
unsafe {
let leaf = x86_64::__cpuid(0x0);