[pbs-devel] [PATCH proxmox 4/9] broadcast_future: accommodate to edition 2024 changes to RPIT
Maximiliano Sandoval
m.sandoval at proxmox.com
Tue Mar 4 15:40:46 CET 2025
Prevents the following error:
```
error[E0597]: `inner` does not live long enough
--> proxmox-async/src/broadcast_future.rs:109:24
|
107 | inner: Arc<Mutex<BroadCastFutureBinding<T>>>,
| ----- binding `inner` declared here
108 | ) -> impl Future<Output = Result<T, Error>> {
109 | let mut data = inner.lock().unwrap();
| ^^^^^ borrowed value does not live long enough
...
121 | data.broadcast.listen()
| ----------------------- argument requires that `inner` is borrowed for `'static`
122 | }
| - `inner` dropped here while still borrowed
error[E0597]: `data` does not live long enough
--> proxmox-async/src/broadcast_future.rs:121:9
|
109 | let mut data = inner.lock().unwrap();
| -------- binding `data` declared here
...
121 | data.broadcast.listen()
| ^^^^-------------------
| |
| borrowed value does not live long enough
| argument requires that `data` is borrowed for `'static`
122 | }
| - `data` dropped here while still borrowed
```
The use<...> pattern was introduced in rust 1.82.
Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
Cargo.toml | 2 +-
proxmox-async/src/broadcast_future.rs | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 4d3f633e..3d758e92 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -62,7 +62,7 @@ license = "AGPL-3"
repository = "https://git.proxmox.com/?p=proxmox.git"
homepage = "https://proxmox.com"
exclude = [ "debian" ]
-rust-version = "1.80"
+rust-version = "1.82"
[workspace.dependencies]
# any features enabled here are enabled on all members using 'workspace = true'!
diff --git a/proxmox-async/src/broadcast_future.rs b/proxmox-async/src/broadcast_future.rs
index 838204d3..62982e13 100644
--- a/proxmox-async/src/broadcast_future.rs
+++ b/proxmox-async/src/broadcast_future.rs
@@ -43,7 +43,7 @@ impl<T: Clone> BroadcastData<T> {
}
}
- pub fn listen(&mut self) -> impl Future<Output = Result<T, Error>> {
+ pub fn listen(&mut self) -> impl Future<Output = Result<T, Error>> + use<T> {
use futures::future::{ok, Either};
match &self.result {
@@ -105,7 +105,7 @@ impl<T: Clone + Send + 'static> BroadcastFuture<T> {
fn spawn(
inner: Arc<Mutex<BroadCastFutureBinding<T>>>,
- ) -> impl Future<Output = Result<T, Error>> {
+ ) -> impl Future<Output = Result<T, Error>> + use<T> {
let mut data = inner.lock().unwrap();
if let Some(source) = data.future.take() {
@@ -122,7 +122,7 @@ impl<T: Clone + Send + 'static> BroadcastFuture<T> {
}
/// Register a listener
- pub fn listen(&self) -> impl Future<Output = Result<T, Error>> {
+ pub fn listen(&self) -> impl Future<Output = Result<T, Error>> + use<T> {
let inner2 = self.inner.clone();
async move { Self::spawn(inner2).await }
}
--
2.39.5
More information about the pbs-devel
mailing list