Impl trait always captures lifetimes of arg types

See this:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=82f07e9346058fc2949c235c97cc2ff0

it appears that the return type from create_static still captures the lifetime of its argument _s, despite being declared as + 'static, and that argument not being used. Which seems odd, especially since if you replace S with &str in args of both alpha and create_static, it works fine (the return type doesn't capture the unnamed lifetime of &str).

What am I missing here, and/or is there a way to use impl Trait in the return position to indicate that the returned impl is 'static?

This is issue #42940:

Ah, this makes sense. I've worked around the issue in my project, and eagerly wait for the resolution to the issue. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.