Skip to content

Fixup return position impl trait overcapturing for the 2024 edition #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions openhcl/openhcl_boot/src/host_params/dt.rs
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ fn allocate_vtl2_ram(
params: &ShimParams,
partition_memory_map: &[MemoryEntry],
ram_size: Option<u64>,
) -> 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<u32, MAX_NUMA_NODES>, 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<MemoryEntry, MAX_NUMA_NODES>, ArrayVec::new_const());
2 changes: 1 addition & 1 deletion openhcl/openhcl_boot/src/host_params/mod.rs
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ impl PartitionInfo {
}

/// Returns the parameter regions that are not being reclaimed.
pub fn vtl2_config_regions(&self) -> impl Iterator<Item = MemoryRange> {
pub fn vtl2_config_regions(&self) -> impl Iterator<Item = MemoryRange> + use<> {
subtract_ranges(
[self.vtl2_full_config_region],
[self.vtl2_config_region_reclaim],
2 changes: 1 addition & 1 deletion openhcl/openhcl_boot/src/main.rs
Original file line number Diff line number Diff line change
@@ -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(
12 changes: 6 additions & 6 deletions openvmm/openvmm_entry/src/ttrpc/mod.rs
Original file line number Diff line number Diff line change
@@ -364,7 +364,7 @@ impl VmService {
&self,
ctx: mesh::CancelContext,
request: inspect_proto::InspectRequest,
) -> impl Future<Output = anyhow::Result<InspectResponse2>> {
) -> impl Future<Output = anyhow::Result<InspectResponse2>> + 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<Output = anyhow::Result<UpdateResponse2>> {
) -> impl Future<Output = anyhow::Result<UpdateResponse2>> + 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<Output = anyhow::Result<()>> {
fn pause_vm(&mut self, vm: &Vm) -> impl Future<Output = anyhow::Result<()>> + 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<Output = anyhow::Result<()>> {
fn resume_vm(&mut self, vm: &Vm) -> impl Future<Output = anyhow::Result<()>> + 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<Vm>,
) -> anyhow::Result<impl Future<Output = anyhow::Result<()>>> {
) -> anyhow::Result<impl Future<Output = 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<impl Future<Output = anyhow::Result<()>>> {
) -> anyhow::Result<impl Future<Output = anyhow::Result<()>> + use<>> {
use vmservice::modify_resource_request::Resource;
match request.resource.context("missing resource")? {
Resource::ScsiDisk(disk) => {
2 changes: 1 addition & 1 deletion support/fdt/src/parser.rs
Original file line number Diff line number Diff line change
@@ -671,7 +671,7 @@ impl<'a> Property<'a> {
}

/// Read data as an iterator of u64 values.
pub fn as_64_list(&self) -> Result<impl Iterator<Item = u64> + 'a, Error<'a>> {
pub fn as_64_list(&self) -> Result<impl Iterator<Item = u64> + use<'a>, Error<'a>> {
Ok(U64b::slice_from(self.data)
.ok_or(Error(ErrorKind::PropertyDataTypeBuffer {
node_name: self.node_name,
2 changes: 1 addition & 1 deletion support/mesh/mesh_protobuf/src/protobuf.rs
Original file line number Diff line number Diff line change
@@ -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<Item = Result<R>> {
pub fn take_resources(&mut self) -> impl ExactSizeIterator<Item = Result<R>> + use<'b, R> {
let state = self.state;
self.resources.clone().map(move |i| {
state
2 changes: 1 addition & 1 deletion vm/devices/pci/pci_core/src/capabilities/msix.rs
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion vm/devices/storage/disk_nvme/nvme_driver/src/driver.rs
Original file line number Diff line number Diff line change
@@ -452,7 +452,7 @@ impl<T: DeviceBacking> NvmeDriver<T> {
drop(self);
}

fn reset(&mut self) -> impl 'static + Send + std::future::Future<Output = ()> {
fn reset(&mut self) -> impl Send + std::future::Future<Output = ()> + use<T> {
let driver = self.driver.clone();
let mut task = std::mem::take(&mut self.task).unwrap();
async move {
2 changes: 1 addition & 1 deletion vm/devices/vmbus/vmbus_client/src/lib.rs
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ impl VmbusClientAccess {
pub fn connect_hvsock(
&self,
request: HvsockConnectRequest,
) -> impl Future<Output = Option<OfferInfo>> {
) -> impl Future<Output = Option<OfferInfo>> + use<> {
self.client_request_send
.call(ClientRequest::HvsockConnect, request)
.map(|r| r.ok().flatten())
6 changes: 3 additions & 3 deletions vm/devices/vmbus/vmbus_client_hcl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<T: Driver + ?Sized>(
driver: &T,
) -> anyhow::Result<(impl SynicClient + use<T>, impl VmbusMessageSource + use<T>)> {
// 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 {
2 changes: 1 addition & 1 deletion vm/devices/vmbus/vmbus_server/src/hvsock.rs
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ impl HvsockRelay {
&self,
ctx: &mut CancelContext,
service_id: Guid,
) -> impl std::future::Future<Output = anyhow::Result<UnixStream>> + Send {
) -> impl std::future::Future<Output = anyhow::Result<UnixStream>> + Send + use<> {
let inner = self.inner.clone();
let host_send = self.host_send.clone();
let (send, recv) = mesh::oneshot();
6 changes: 3 additions & 3 deletions vmm_core/state_unit/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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<I: 'static, R: 'static + Send>(
fn state_change<I: 'static, R: 'static + Send, Req: FnOnce(Rpc<I, R>) -> StateRequest>(
name: Arc<str>,
unit: &Unit,
request: impl FnOnce(Rpc<I, R>) -> StateRequest,
request: Req,
input: Option<I>,
) -> impl Future<Output = Result<Option<R>, UnitRecvError>> {
) -> impl Future<Output = Result<Option<R>, UnitRecvError>> + use<I, R, Req> {
let send = unit.send.clone();

async move {
2 changes: 1 addition & 1 deletion vmm_core/virt_whp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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")
}
2 changes: 1 addition & 1 deletion vmm_core/virt_whp/src/vtl2.rs
Original file line number Diff line number Diff line change
@@ -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)
}