Casting away lifetimes using closures #65700
Labels
A-closures
Area: Closures (`|…| { … }`)
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
The following code compiles on stable and nightly. I'm not sure it should as it's effectively casting a
Struct::<'a>
to aStruct::<'static>
in safe code.(Playground)
It seems lifetime and type parameters that are used in the closure don't affect the lifetime of the closure itself. I stumbled upon this after noticing that
|| T::default()
is'static
whereasT::default()
is not.The text was updated successfully, but these errors were encountered: