Inconsistent lifetime inference when using impl Trait
reference in function return position
#116639
Labels
C-bug
Category: This is a bug.
F-return_position_impl_trait_in_trait
`#![feature(return_position_impl_trait_in_trait)]`
Given that this is using an unstable feature, I'm not sure if a bug report is appropriate, but I thought it might be useful information for those working on #99697.
I tried this code:
I expected this to compile. If I add a generic
N: M<...>
above and return a reference to it instead in the trait, it does work.Instead when using the
&'a impl M<...>
, the compiler insists that 'b needs to live longer than 'a, which I think is an overly restrictive inference that prevents efficient memory management as it cannot be bypassed.Meta
rustc +nightly --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: