-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
Consider the following crate (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:
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:
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.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.