all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 4/9] broadcast_future: accommodate to edition 2024 changes to RPIT
Date: Tue,  4 Mar 2025 15:40:46 +0100	[thread overview]
Message-ID: <20250304144051.585163-4-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250304144051.585163-1-m.sandoval@proxmox.com>

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@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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2025-03-04 14:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04 14:40 [pbs-devel] [PATCH proxmox 1/9] mark extern C blocks as unsafe Maximiliano Sandoval
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 2/9] daemon: set_var is now unsafe Maximiliano Sandoval
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 3/9] mark blocks inside unsafe fns unsafe Maximiliano Sandoval
2025-03-04 14:40 ` Maximiliano Sandoval [this message]
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 5/9] procfs: add variable bindings for std::fs::read Maximiliano Sandoval
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 6/9] port to edition 2024 Maximiliano Sandoval
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 7/9] run rustfmt with " Maximiliano Sandoval
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 8/9] run cargo clippy --fix Maximiliano Sandoval
2025-03-04 14:40 ` [pbs-devel] [PATCH proxmox 9/9] manual clippy fixes Maximiliano Sandoval
2025-03-19 11:34 ` [pbs-devel] partially-applied: [PATCH proxmox 1/9] mark extern C blocks as unsafe Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250304144051.585163-4-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal