From 7d1ef9bc443062a88541353df71ac1a5555ba7eb Mon Sep 17 00:00:00 2001 From: Steven Malis Date: Wed, 18 Dec 2024 13:45:47 -0500 Subject: [PATCH 1/4] Fixup impl trait overcapturing for the 2024 edition --- Cargo.toml | 3 +-- openhcl/openhcl_boot/src/host_params/dt.rs | 4 ++-- openhcl/openhcl_boot/src/host_params/mod.rs | 2 +- openhcl/openhcl_boot/src/main.rs | 2 +- openvmm/openvmm_entry/src/ttrpc/mod.rs | 12 ++++++------ support/fdt/src/parser.rs | 2 +- support/mesh/mesh_protobuf/src/protobuf.rs | 2 +- vm/devices/pci/pci_core/src/capabilities/msix.rs | 2 +- .../storage/disk_nvme/nvme_driver/src/driver.rs | 2 +- vm/devices/vmbus/vmbus_client_hcl/src/lib.rs | 6 +++--- vm/devices/vmbus/vmbus_server/src/hvsock.rs | 2 +- vmm_core/state_unit/src/lib.rs | 6 +++--- 12 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8ad4aef32..b4a4b08c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -588,9 +588,8 @@ nonstandard_style = { level = "deny", priority = -2 } rust_2018_idioms = { level = "deny", priority = -2 } rust-2024-compatibility = { level = "warn", priority = -1 } -# TODO: Fix all of the below, https://github.com/microsoft/openvmm/issues/288 edition_2024_expr_fragment_specifier = "allow" -impl_trait_overcaptures = "allow" +# TODO: Fix all of the below, https://github.com/microsoft/openvmm/issues/288 deprecated-safe-2024 = "allow" tail-expr-drop-order = "allow" if-let-rescope = "allow" diff --git a/openhcl/openhcl_boot/src/host_params/dt.rs b/openhcl/openhcl_boot/src/host_params/dt.rs index 6c7a05428..a32e6c98e 100644 --- a/openhcl/openhcl_boot/src/host_params/dt.rs +++ b/openhcl/openhcl_boot/src/host_params/dt.rs @@ -69,7 +69,7 @@ fn allocate_vtl2_ram( params: &ShimParams, partition_memory_map: &[MemoryEntry], ram_size: Option, -) -> OffStackRef<'static, impl AsRef<[MemoryEntry]>> { +) -> OffStackRef<'static, impl AsRef<[MemoryEntry]> + use<>> { // First, calculate how many numa nodes there are by looking at unique numa // nodes in the memory map. let mut numa_nodes = off_stack!(ArrayVec, ArrayVec::new_const()); @@ -262,7 +262,7 @@ fn allocate_vtl2_ram( fn parse_host_vtl2_ram( params: &ShimParams, memory: &[MemoryEntry], -) -> OffStackRef<'static, impl AsRef<[MemoryEntry]>> { +) -> OffStackRef<'static, impl AsRef<[MemoryEntry]> + use<>> { // If no VTL2 protectable ram was provided by the host, use the build time // value encoded in ShimParams. let mut vtl2_ram = off_stack!(ArrayVec, ArrayVec::new_const()); diff --git a/openhcl/openhcl_boot/src/host_params/mod.rs b/openhcl/openhcl_boot/src/host_params/mod.rs index 9c1bf141f..e35abf286 100644 --- a/openhcl/openhcl_boot/src/host_params/mod.rs +++ b/openhcl/openhcl_boot/src/host_params/mod.rs @@ -126,7 +126,7 @@ impl PartitionInfo { } /// Returns the parameter regions that are not being reclaimed. - pub fn vtl2_config_regions(&self) -> impl Iterator { + pub fn vtl2_config_regions(&self) -> impl Iterator + use<> { subtract_ranges( [self.vtl2_full_config_region], [self.vtl2_config_region_reclaim], diff --git a/openhcl/openhcl_boot/src/main.rs b/openhcl/openhcl_boot/src/main.rs index 775953f3c..b0154c935 100644 --- a/openhcl/openhcl_boot/src/main.rs +++ b/openhcl/openhcl_boot/src/main.rs @@ -314,7 +314,7 @@ enum ReservedMemoryType { fn reserved_memory_regions( partition_info: &PartitionInfo, sidecar: Option<&SidecarConfig<'_>>, -) -> OffStackRef<'static, impl AsRef<[(MemoryRange, ReservedMemoryType)]>> { +) -> OffStackRef<'static, impl AsRef<[(MemoryRange, ReservedMemoryType)]> + use<>> { let mut reserved = off_stack!(ArrayVec<(MemoryRange, ReservedMemoryType), MAX_RESERVED_MEM_RANGES>, ArrayVec::new_const()); reserved.clear(); reserved.extend( diff --git a/openvmm/openvmm_entry/src/ttrpc/mod.rs b/openvmm/openvmm_entry/src/ttrpc/mod.rs index 579138f77..1ab0b2a0c 100644 --- a/openvmm/openvmm_entry/src/ttrpc/mod.rs +++ b/openvmm/openvmm_entry/src/ttrpc/mod.rs @@ -364,7 +364,7 @@ impl VmService { &self, ctx: mesh::CancelContext, request: inspect_proto::InspectRequest, - ) -> impl Future> { + ) -> impl Future> + use<> { let mut inspection = InspectionBuilder::new(&request.path) .depth(Some(request.depth as usize)) .inspect(inspect::adhoc(|req| { @@ -387,7 +387,7 @@ impl VmService { &self, ctx: mesh::CancelContext, request: inspect_proto::UpdateRequest, - ) -> impl Future> { + ) -> impl Future> + use<> { let update = inspect::update( &request.path, &request.value, @@ -603,12 +603,12 @@ impl VmService { Ok(()) } - fn pause_vm(&mut self, vm: &Vm) -> impl Future> { + fn pause_vm(&mut self, vm: &Vm) -> impl Future> + use<> { let recv = vm.worker_rpc.call(VmRpc::Pause, ()); async move { recv.await.map(drop).context("pause failed") } } - fn resume_vm(&mut self, vm: &Vm) -> impl Future> { + fn resume_vm(&mut self, vm: &Vm) -> impl Future> + use<> { let recv = vm.worker_rpc.call(VmRpc::Resume, ()); async move { recv.await.map(drop).context("resume failed") } } @@ -617,7 +617,7 @@ impl VmService { &mut self, mut ctx: mesh::CancelContext, vm: Arc, - ) -> anyhow::Result>> { + ) -> anyhow::Result> + use<>> { let mut notify_recv = vm .notify_recv .lock() @@ -642,7 +642,7 @@ impl VmService { &mut self, vm: &Vm, request: vmservice::ModifyResourceRequest, - ) -> anyhow::Result>> { + ) -> anyhow::Result> + use<>> { use vmservice::modify_resource_request::Resource; match request.resource.context("missing resource")? { Resource::ScsiDisk(disk) => { diff --git a/support/fdt/src/parser.rs b/support/fdt/src/parser.rs index 492765477..c80abaaf7 100644 --- a/support/fdt/src/parser.rs +++ b/support/fdt/src/parser.rs @@ -671,7 +671,7 @@ impl<'a> Property<'a> { } /// Read data as an iterator of u64 values. - pub fn as_64_list(&self) -> Result + 'a, Error<'a>> { + pub fn as_64_list(&self) -> Result + use<'a>, Error<'a>> { Ok(U64b::slice_from(self.data) .ok_or(Error(ErrorKind::PropertyDataTypeBuffer { node_name: self.node_name, diff --git a/support/mesh/mesh_protobuf/src/protobuf.rs b/support/mesh/mesh_protobuf/src/protobuf.rs index 6b7f013d7..b65aecaba 100644 --- a/support/mesh/mesh_protobuf/src/protobuf.rs +++ b/support/mesh/mesh_protobuf/src/protobuf.rs @@ -666,7 +666,7 @@ impl<'a, 'b, R> MessageReader<'a, 'b, R> { } /// Returns an iterator to consume the resources for this message. - pub fn take_resources(&mut self) -> impl 'b + ExactSizeIterator> { + pub fn take_resources(&mut self) -> impl ExactSizeIterator> + use<'b, R> { let state = self.state; self.resources.clone().map(move |i| { state diff --git a/vm/devices/pci/pci_core/src/capabilities/msix.rs b/vm/devices/pci/pci_core/src/capabilities/msix.rs index 8d69f416c..34c395413 100644 --- a/vm/devices/pci/pci_core/src/capabilities/msix.rs +++ b/vm/devices/pci/pci_core/src/capabilities/msix.rs @@ -233,7 +233,7 @@ impl MsixEmulator { bar: u8, count: u16, register_msi: &mut dyn RegisterMsi, - ) -> (Self, impl PciCapability) { + ) -> (Self, impl PciCapability + use<>) { let state = MsixState { enabled: false, vectors: (0..count) diff --git a/vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs b/vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs index b51074e8b..d243b7110 100644 --- a/vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs +++ b/vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs @@ -452,7 +452,7 @@ impl NvmeDriver { drop(self); } - fn reset(&mut self) -> impl 'static + Send + std::future::Future { + fn reset(&mut self) -> impl Send + std::future::Future + use { let driver = self.driver.clone(); let mut task = std::mem::take(&mut self.task).unwrap(); async move { diff --git a/vm/devices/vmbus/vmbus_client_hcl/src/lib.rs b/vm/devices/vmbus/vmbus_client_hcl/src/lib.rs index 0c1cafbc6..6b35b8170 100644 --- a/vm/devices/vmbus/vmbus_client_hcl/src/lib.rs +++ b/vm/devices/vmbus/vmbus_client_hcl/src/lib.rs @@ -32,9 +32,9 @@ use zerocopy::AsBytes; /// Returns the synic client and message source for use with /// [`vmbus_client::VmbusClient`]. -pub fn new_synic_client_and_messsage_source( - driver: &(impl Driver + ?Sized), -) -> anyhow::Result<(impl SynicClient, impl VmbusMessageSource)> { +pub fn new_synic_client_and_messsage_source( + driver: &T, +) -> anyhow::Result<(impl SynicClient + use, impl VmbusMessageSource + use)> { // Open an HCL vmbus fd for issuing synic requests. let hcl_vmbus = Arc::new(HclVmbus::new().context("failed to open hcl_vmbus")?); let synic = HclSynic { diff --git a/vm/devices/vmbus/vmbus_server/src/hvsock.rs b/vm/devices/vmbus/vmbus_server/src/hvsock.rs index e41c3b800..4f810146a 100644 --- a/vm/devices/vmbus/vmbus_server/src/hvsock.rs +++ b/vm/devices/vmbus/vmbus_server/src/hvsock.rs @@ -114,7 +114,7 @@ impl HvsockRelay { &self, ctx: &mut CancelContext, service_id: Guid, - ) -> impl std::future::Future> + Send { + ) -> impl std::future::Future> + Send + use<> { let inner = self.inner.clone(); let host_send = self.host_send.clone(); let (send, recv) = mesh::oneshot(); diff --git a/vmm_core/state_unit/src/lib.rs b/vmm_core/state_unit/src/lib.rs index b1a3561b3..c70a95b28 100644 --- a/vmm_core/state_unit/src/lib.rs +++ b/vmm_core/state_unit/src/lib.rs @@ -888,12 +888,12 @@ impl ReadySet { /// future with a span, and wrapping its error with something more informative. /// /// `operation` and `name` are used in tracing and error construction. -fn state_change( +fn state_change) -> StateRequest>( name: Arc, unit: &Unit, - request: impl FnOnce(Rpc) -> StateRequest, + request: Req, input: Option, -) -> impl Future, UnitRecvError>> { +) -> impl Future, UnitRecvError>> + use { let send = unit.send.clone(); async move { From 1d1caaebffe3105be0826e1699d2e12781f30e2c Mon Sep 17 00:00:00 2001 From: Steven Malis Date: Wed, 18 Dec 2024 15:17:51 -0500 Subject: [PATCH 2/4] and windows --- vmm_core/virt_whp/src/vtl2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmm_core/virt_whp/src/vtl2.rs b/vmm_core/virt_whp/src/vtl2.rs index 935100e10..dbb3d20e4 100644 --- a/vmm_core/virt_whp/src/vtl2.rs +++ b/vmm_core/virt_whp/src/vtl2.rs @@ -190,7 +190,7 @@ pub(crate) struct Vtl2Emulation { mod inspect_helpers { use super::*; - pub(super) fn vsm_config_raw(raw: &AtomicU64) -> impl Inspect { + pub(super) fn vsm_config_raw(raw: &AtomicU64) -> impl Inspect + use<> { let config = HvRegisterVsmPartitionConfig::from(raw.load(Ordering::Relaxed)); inspect::AsDebug(config) } From 05465be524ad799abaf6279053b2e5a204018ed1 Mon Sep 17 00:00:00 2001 From: Steven Malis Date: Tue, 14 Jan 2025 12:04:26 -0500 Subject: [PATCH 3/4] Fix new instance --- vm/devices/vmbus/vmbus_client/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm/devices/vmbus/vmbus_client/src/lib.rs b/vm/devices/vmbus/vmbus_client/src/lib.rs index 220ab2de1..086b02846 100644 --- a/vm/devices/vmbus/vmbus_client/src/lib.rs +++ b/vm/devices/vmbus/vmbus_client/src/lib.rs @@ -221,7 +221,7 @@ impl VmbusClientAccess { pub fn connect_hvsock( &self, request: HvsockConnectRequest, - ) -> impl Future> { + ) -> impl Future> + use<> { self.client_request_send .call(ClientRequest::HvsockConnect, request) .map(|r| r.ok().flatten()) From 90255bee4b17b6bca03cdca37eef2c82ef4ac1d6 Mon Sep 17 00:00:00 2001 From: Steven Malis Date: Tue, 14 Jan 2025 12:14:06 -0500 Subject: [PATCH 4/4] Fix arm windows --- vmm_core/virt_whp/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vmm_core/virt_whp/src/lib.rs b/vmm_core/virt_whp/src/lib.rs index 79e883199..852faa357 100644 --- a/vmm_core/virt_whp/src/lib.rs +++ b/vmm_core/virt_whp/src/lib.rs @@ -1642,7 +1642,7 @@ mod aarch64 { &self, vp: VpIndex, vtl: Vtl, - ) -> impl hv1_emulator::RequestInterrupt { + ) -> impl hv1_emulator::RequestInterrupt + use<> { let _ = (vp, vtl); move |_vec, _auto_eoi| todo!("TODO-aarch64") }