Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@jethrogb

Description

@jethrogb
Issue body actions
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language teamRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.