Skip to content

Non-exported type in exported type signature does not error #29668

Closed

Description

mod m1 {
    struct A;
    pub fn x() -> A { A }
}

fn main() {
    let x=m1::x();
    println!("{:?}",&x as *const _ as *const u8);
}

This generates an error:

<anon>:3:16: 3:17 error: private type in exported type signature [E0446]
<anon>:3    pub fn x() -> A { A }
                          ^

Yet this compiles fine:

mod m1 {
    mod m2 { pub struct A; }
    use self::m2::A as A;
    pub fn x() -> A { A }
}

fn main() {
    let x=m1::x();
    println!("{:?}",&x as *const _ as *const u8);
}

However, one is unable to specify the return type of m1::x() outside of m1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions