# Can a future used only by \`async fn\` assume it won't be polled again after becoming ready?

**URL:** <https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263>\
**Category:** help\
**Created:** [March 30, 2026, 8:32am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263 "2026-03-30T08:32:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobsa](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/jacobsa/32/51717_2.png) [@jacobsa](https://users.rust-lang.org/u/jacobsa)\
**Post date:** [March 30, 2026, 8:32am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/1 "2026-03-30T08:32:27Z")

</div>

Are there any guarantees about what an `async fn` will do if its future is polled again after it completes? In particular, given the following situation…

```rust
pub async fn foo(foo: Foo) {
    // We await the Foo, then never use it again.
    foo.await;
}

struct Foo;

impl Future for Foo {
    type Output = ();

    fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<()> {
        todo!();
    }
}

```

…I'm wondering whether `Foo::poll` can assume that it will never be called again after returning `Poll::Ready`. I know that assumption is not sound [in general](https://doc.rust-lang.org/std/future/trait.Future.html#tymethod.poll), but I can imagine that in the case where you know all callers are `.await` expressions in `async fn`s that own the future it might be okay, assuming that the `async fn`s already have their own "panic if polled again after completion" logic internally.

---

<div class="post-metadata">

**Author:** ![nerditation](https://avatars.discourse-cdn.com/v4/letter/n/e79b87/32.png) [@nerditation](https://users.rust-lang.org/u/nerditation)\
**Post date:** [March 30, 2026, 9:42am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/2 "2026-03-30T09:42:33Z")

</div>

> [@jacobsa](#):
>
> in the case where you know all callers are `.await` expressions in `async fn`s that own the future it might be okay, ...

this is only true, if you are in control of both the caller and callee.

but this is not specific to `Future` polling, it's just you have the knowledge of how a piece of code will be used. if your type can be used by third party code, then nothing can be said for sure.

> [@jacobsa](#):
>
> ... assuming that the `async fn`s already have their own "panic if polled again after completion" logic internally.

as far as I know, the synthetic `Future` of the `async fn` sugar would indeed panic if polled again after `Ready`, but it is only for the synthetic type itself, since it is desugared like a state machine.

but it guarantees nothing about the behavior of "inner" futures, which is completely determined how the `async fn` is using the type.

for "normal" code, you only `.await` the future once, but note this blanket implementation in the standard library:

```rust
impl<F> Future for &mut F where F: Future {
    //...
}

```

this can be abused to make it possible to `.await` a future multiple times, and there's no `unsafe` needed. example:

> **[Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=7298f1c494b19c90e27392a2f93f450e)**
>
> A browser interface to the Rust compiler to experiment with the language

---

<div class="post-metadata">

**Author:** ![alice](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/alice/32/9777_2.png) [@alice](https://users.rust-lang.org/u/alice)\
**Post date:** [March 30, 2026, 10:43am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/3 "2026-03-30T10:43:05Z")

</div>

The current implementation of `async fn` will never invoke `poll` of a sub-future after `Ready`.

But in principle I could see a possibility that if you poll an `async fn` future after `Ready`, it could be okay for that future to invoke `poll` on the last `.await` statement in its body again.

---

<div class="post-metadata">

**Author:** ![Morgane55440](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/morgane55440/32/50376_2.png) [@Morgane55440](https://users.rust-lang.org/u/Morgane55440)\
**Post date:** [March 30, 2026, 12:21pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/4 "2026-03-30T12:21:52Z")

</div>

you should indeed assume that it won't be polled again, which is why you should `panic!` if it is.

in the current impl `.await` will not poll again after receiving ready, and all `async` block will `panic!` if polled after completion.

if you are not doing anything `unsafe`, then anything is a reasonable to do if being polled after completion though `panic!` is prob best.

---

<div class="post-metadata">

**Author:** ![SkiFire13](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/skifire13/32/17959_2.png) [@SkiFire13](https://users.rust-lang.org/u/SkiFire13)\
**Post date:** [March 30, 2026, 2:19pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/5 "2026-03-30T14:19:31Z")

</div>

> [@Morgane55440](#):
>
> you should indeed assume that it won't be polled again, which is why you should `panic!` if it is.

If you assume it won't be polled again then there's no reason to put a `panic!()` there, because it will never be hit.

If instead you want it to never be polled again, but it _might_ be, then you want to put a panic or something similar.

---

<div class="post-metadata">

**Author:** ![Morgane55440](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/morgane55440/32/50376_2.png) [@Morgane55440](https://users.rust-lang.org/u/Morgane55440)\
**Post date:** [March 30, 2026, 2:58pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/6 "2026-03-30T14:58:04Z")

</div>

i disagree. panic is for bugs, and as such for broken assumptions. if you assume a code path wil not be reached but cannot prove that it won't. then you should put a panic there because if it is reached then you will know an error has happened.

ultimately this is semantics about what we mean by assume. but when i read "assume", i expect "not certain", or at least "unable to prove", which is where `panic!` fits

---

<div class="post-metadata">

**Author:** ![scottmcm](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/scottmcm/32/4286_2.png) [@scottmcm](https://users.rust-lang.org/u/scottmcm)\
**Post date:** [March 30, 2026, 4:47pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/7 "2026-03-30T16:47:01Z")

</div>

> [@jacobsa](#):
>
> Are there any guarantees about what an `async fn` will do if its future is polled again after it completes?

I would expect no.

In particular, your example is the same as

```rust
pub async fn foo(foo: Foo) {
    return foo.await;
}

```

and I suspect the compiler would like the freedom to say "hey, I see that the only `.await` is returned", and thus just have poll forward on to the inner future -- that avoids adding an unnecessary wrapper at every level.

(Kinda like how `iter::Map` just always calls `next` on the underlying iterator without tracking _itself_ whether that underlying iterator is exhausted.)

---

<div class="post-metadata">

**Author:** ![jacobsa](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/jacobsa/32/51717_2.png) [@jacobsa](https://users.rust-lang.org/u/jacobsa)\
**Post date:** [March 31, 2026, 12:19am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/8 "2026-03-31T00:19:36Z")

</div>

Thanks all. To be clear, I am talking about a situation where I control caller and callee, and relying on this for soundness. If such a guarantee existed from `async fn`, then it would be a waste of CPU cycles to check for it downstream again in a branch that can never be taken.

It sounds like the answer is approximately "this is how `async fn` works today, but it's not guaranteed". Is that correct?

If so, it seems a little unfortunate to have to double check this everywhere. While it's true that not guaranteeing this makes a potential optimization possible, it makes the same optimization on the callee end impossible today, despite the fact that it could otherwise totally work. It seems like one direction or the other could be guaranteed.

---

<div class="post-metadata">

**Author:** ![kornel](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/kornel/32/4823_2.png) [@kornel](https://users.rust-lang.org/u/kornel)\
**Post date:** [March 31, 2026, 1:37pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/9 "2026-03-31T13:37:12Z")

</div>

You can rely on it _except_ where it would cause Undefined Behavior. Your implementation can react badly, but not unsafely.

So you can panic, abort, return dummy data, `loop{}`, or pretend to be pending forever, but you can't cause use-after-free, nor expose deinitialized moved-from memory.

---

<div class="post-metadata">

**Author:** ![jacobsa](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/jacobsa/32/51717_2.png) [@jacobsa](https://users.rust-lang.org/u/jacobsa)\
**Post date:** [March 31, 2026, 8:56pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/10 "2026-03-31T20:56:11Z")

</div>

Guys, I know the rules around futures and UB. I linked to them in my original post. My question is whether there is any additional guarantee for futures awaited exactly once by an `async fn` I control.

(It sounds like the answer is no, which is unfortunate.)

---

<div class="post-metadata">

**Author:** ![Tamschi](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/tamschi/32/17210_2.png) [@Tamschi](https://users.rust-lang.org/u/Tamschi)\
**Post date:** [April 1, 2026, 5:05pm UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/11 "2026-04-01T17:05:51Z")

</div>

It would likely be documented at [async - Rust](https://doc.rust-lang.org/stable/std/keyword.async.html) if it was one way or another, but I suspect it's intentionally kept unspecified because that can make certain kinds of `Future`s (that don't need guards to avoid UB) smaller.  
(Might be a good idea to point out the unspecified behaviour explicitly there.)

It would be possible to make this guarantee with fewer downsides if `poll` passed something like a "`Pin<&'_ own Self>`"\[1\] through to `Pending`. Interestingly, I suspect that pattern could also be used to much more easily mitigate the 'Futurelock' issue discussed here: [Oxide and Friends | Futurelock](https://oxide-and-friends.transistor.fm/episodes/futurelock)

* * *

1. I take no credit for this idea, but I forgot who posted about it. Libraries can model safe owning references but not the `.await` sugar unless a more general trait similar to [`Try`](https://doc.rust-lang.org/stable/std/ops/trait.Try.html) is added and stabilised for that.

---

<div class="post-metadata">

**Author:** ![jacobsa](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/jacobsa/32/51717_2.png) [@jacobsa](https://users.rust-lang.org/u/jacobsa)\
**Post date:** [April 24, 2026, 1:11am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/12 "2026-04-24T01:11:00Z")

</div>

Hi all, I thought about this more and I don't think the consensus above necessairly makes sense. You all seem to think the status quo is appropriate because it allows the compiler to optimize away the last state machine transition (from state that returns to "I have returned" state). But it certainly can't do that in general, as it may introduce UB depending on what that state does.

Here is a super simple example:

```rust
// # Safety
//
// The caller must guarantee the Option is Some.
async unsafe fn take_some<T>(o: &mut Option<T>) -> T {
    unsafe { o.take().unwrap_unchecked() }
}

```

This can be called to obtain a `Future`, which is [explicitly documented](https://github.com/rust-lang/rust/blob/3a56a03f05da6725e4e851c3a18fb5493ab5cd87/library/core/src/future/future.rs#L100-L106) as allowing polling again after completion. As far as I can tell that means the compiler is forced to insert a transition to a state that will panic if polled again or else it will cause UB in safe code like this function:

```rust
fn inefficient_take_that_might_panic<T>(o: &mut Option<T>) -> Option<T> {
    if o.is_none() {
        return None;
    }

    // Safety: we confirmed this is Some.
    let mut future = pin!(unsafe { take_some(o) });

    let result = match future
        .as_mut()
        .poll(&mut Context::from_waker(Waker::noop()))
    {
        Poll::Ready(result) => result,
        _ => std::unreachable!(),
    };

    // Totally valid by the Future docs.
    let _ = future.poll(&mut Context::from_waker(Waker::noop()));

    Some(result)
}

```

I'm pretty sure you can come up with similar examples that don't involve the `unsafe` keyword as well.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [July 23, 2026, 1:11am UTC](https://users.rust-lang.org/t/can-a-future-used-only-by-async-fn-assume-it-wont-be-polled-again-after-becoming-ready/139263/13 "2026-07-23T01:11:28Z")

</div>

Closed on July 23, 2026, 1:11am UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
