False-positive "temporary dropped while borrowed" involving return-position impl Trait #98997
Labels
A-async-await
Area: Async & Await
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I'm getting a "temporary value dropped while borrowed" error from code that I otherwise would expect to compile:
This is a revised version of my original attempt, which fails due to #64477 (comment) (Playground link). After reading through the discussions, I understand why that version doesn't work.
However, I expected the revised version above to work because
takes_display()
should be eagerly evaluated, and thus not hold any temporaries longer than necessary. It may be an overly eager application of the deferred drop rules as.await
is not even involved here, the future returned fromtakes_display()
is explicitly not lifetime-bound to the input, and the return value is bound in alet
statement and is not in return position.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: