Skip to content

Trait visability is not consistent. #10857

Closed
@HildarTheDorf

Description

@HildarTheDorf

Attempting to "pub use module::privatetrait" fails with "trait is private", but it is then possible to use the trait from another crate.

// lib.rs
#[crate_type="lib"];
#[link(name="library",
       vers="0.0",
       package_id="library")];
#[feature(globs)];

//This does not export privatetrait.
pub use module::*;

//This fails with "privatetrait is private"
//pub use module::privatetrait;

pub mod module {
    trait privatetrait {
        fn private();
    }

    pub trait publictrait {
        fn public();
    }
}
// main.rs
extern mod library;

struct bugfinder;

//This does not work (and shouldn't). privatetrait is not exported
/*
impl library::privatetrait for bugfinder {
    fn private() {
    }
}
*/

//This works (and shouldn't).
impl library::module::privatetrait for bugfinder {
    fn private() {
    }
}

//This works (and should).
impl library::publictrait for bugfinder {
    fn public() {
    }
}

fn main() {
}

(lib.rs is one crate, main.rs is another.)

This was compiled with master as of 67aca9c.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-visibilityArea: Visibility / privacy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions