Unexpected "the parameter type T
may not live long enough" at a point where T
is not relevant
#80675
Labels
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
A-lifetimes
Area: Lifetimes / regions
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
This code fails to compile at the
Box::new(foo)
line witherror[E0310]: the parameter type `B` may not live long enough
.My understanding is that at that point we have a variable of type
{impl Foo}
andFoo: 'static
. If we move the boxing codeto a function (
box_foo
) the code compiles.(Playground)
The compiler suggestion works, but adds an unwanted constrain on the
bar
field. The struct may want to build a'static
value from a non-static reference.rustc --version --verbose
:The text was updated successfully, but these errors were encountered: