returning a future from a function with an impl Trait
argument references that argument even if not used in the future, causing lifetime errors
#125341
Labels
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
F-precise_capturing
`#![feature(precise_capturing)]`
WG-async
Working group: Async & await
I minimized an error I encountered into this reproduction: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=85de243a39f64d49d42939066a2a824c
This should compile.
Instead, this happened:
The function argument is unused and it doesn't make sense that it should be borrowed for
'static
.If the
impl AsRef<[u64]>
argument is changed to&[u64]
the snippet compiles fine. It seems like anyimpl Trait
argument passed by value will cause the issue.In the original non-minimized code, the argument wasn't unused, but only used outside the returned future.
Meta
repros on stable as well as latest nightly (1.80.0-nightly 2024-05-19 d84b903)
cc @morgangallant
The text was updated successfully, but these errors were encountered: