Skip to content
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

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Expand Up @@ -581,9 +581,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"

unused_qualifications = "warn"
Expand Down
4 changes: 2 additions & 2 deletions openhcl/openhcl_boot/src/host_params/dt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion openhcl/openhcl_boot/src/host_params/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion openhcl/openhcl_boot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions openvmm/openvmm_entry/src/ttrpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,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| {
Expand All @@ -388,7 +388,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,
Expand Down Expand Up @@ -604,13 +604,13 @@ 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 (send, recv) = mesh::oneshot();
vm.worker_rpc.send(VmRpc::Pause(Rpc((), send)));
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 (send, recv) = mesh::oneshot();
vm.worker_rpc.send(VmRpc::Resume(Rpc((), send)));
async move { recv.await.map(drop).context("resume failed") }
Expand All @@ -620,7 +620,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()
Expand All @@ -645,7 +645,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) => {
Expand Down
2 changes: 1 addition & 1 deletion support/fdt/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion support/mesh/mesh_protobuf/src/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
Expand Up @@ -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)
Expand Down
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
Expand Up @@ -444,7 +444,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 {
Expand Down
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
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion vm/devices/vmbus/vmbus_server/src/hvsock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions vmm_core/state_unit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,12 +887,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 (response_send, response_recv) = oneshot();
let send = unit.send.clone();

Expand Down
2 changes: 1 addition & 1 deletion vmm_core/virt_whp/src/vtl2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading