Skip to content

Type alias definition changed during reexport #60113

New issue

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

Open
Disasm opened this issue Apr 19, 2019 · 2 comments
Open

Type alias definition changed during reexport #60113

Disasm opened this issue Apr 19, 2019 · 2 comments
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Disasm
Copy link
Contributor

Disasm commented Apr 19, 2019

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.

@Disasm
Copy link
Contributor Author

Disasm commented Apr 19, 2019

@fatemender, correct me if I'm wrong somewhere.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 19, 2019
@Disasm
Copy link
Contributor Author

Disasm commented Feb 11, 2020

Triage: on rustc 1.41.0 (5e1a79984 2020-01-27) the issue is still present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants