Free functions and trait methods that return impl Trait capture lifetimes differently (edition 2021) #132759
Labels
C-discussion
Category: Discussion or questions that doesn't represent real issues.
I tried this code:
I expected to see this happen: Either both calls to
GetMyTrait::get
andget
should pass or fail. With the new 2024 capture rules, I think they should fail withoutuse<>
, and with the old rules (from RFC3617):So, currently, it should pass.
Instead, this happened: The free function doesn't capture the lifetime of
&self
in the return typeimpl MyTrait
, so themap
method passes. The trait method, however, seems to capture the lifetime, causingmap
to fail.Meta
rustc --version --verbose
:(The bug happens also on nightly.)
The text was updated successfully, but these errors were encountered: