We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider the following crate (test2):
test2
pub trait Foo { } pub type FooDyn = dyn Foo; pub struct Bar; impl Bar { pub fn bar(&self) -> &FooDyn { unimplemented!(); } }
Documentation for this crate says that FooDyn and bar signatures are the following:
FooDyn
bar
type FooDyn = dyn Foo; pub fn bar(&self) -> &FooDyn
You can assume that according to the lifetime elision rules you will get the following equivalent signature:
pub fn bar(&'a self) -> &'a FooDyn
However, it's not true. If you reexport FooDyn and Bar types in another crate (test1), you will get the following signatures in test1 crate:
Bar
test1
type FooDyn = dyn Foo + 'static; pub fn bar(&self) -> &(dyn Foo + 'static)
One of the ways of resolving the issue is the following declaration:
pub type FooDyn<'a> = dyn 'a + Foo;
As for me, it's strange to have 'static lifetime here by default, so maybe there should be an error if lifetime is omitted.
'static
The text was updated successfully, but these errors were encountered:
@fatemender, correct me if I'm wrong somewhere.
Sorry, something went wrong.
Triage: on rustc 1.41.0 (5e1a79984 2020-01-27) the issue is still present.
rustc 1.41.0 (5e1a79984 2020-01-27)
No branches or pull requests
Consider the following crate (
test2
):Documentation for this crate says that
FooDyn
andbar
signatures are the following:You can assume that according to the lifetime elision rules you will get the following equivalent signature:
However, it's not true. If you reexport
FooDyn
andBar
types in another crate (test1
), you will get the following signatures intest1
crate:One of the ways of resolving the issue is the following declaration:
As for me, it's strange to have
'static
lifetime here by default, so maybe there should be an error if lifetime is omitted.The text was updated successfully, but these errors were encountered: