2016-04-10 06:52:25 -05:00
|
|
|
// aux-build:pub_restricted.rs
|
|
|
|
|
|
|
|
#![allow(warnings)]
|
|
|
|
extern crate pub_restricted;
|
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub mod bar {
|
|
|
|
pub(super) fn f() {}
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct S {
|
|
|
|
pub(super) x: i32,
|
|
|
|
}
|
|
|
|
impl S {
|
|
|
|
pub(super) fn f(&self) {}
|
|
|
|
pub(super) fn g() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn f() {
|
|
|
|
use foo::bar::S;
|
|
|
|
pub(self) use foo::bar::f; // ok
|
2018-01-12 15:41:45 -06:00
|
|
|
pub(super) use foo::bar::f as g; //~ ERROR cannot be re-exported
|
2016-04-10 06:52:25 -05:00
|
|
|
S::default().x; // ok
|
|
|
|
S::default().f(); // ok
|
|
|
|
S::g(); // ok
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn f() {
|
|
|
|
use foo::bar::S;
|
|
|
|
use foo::bar::f; //~ ERROR private
|
|
|
|
S::default().x; //~ ERROR private
|
|
|
|
S::default().f(); //~ ERROR private
|
|
|
|
S::g(); //~ ERROR private
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
use pub_restricted::Universe;
|
|
|
|
use pub_restricted::Crate; //~ ERROR private
|
|
|
|
|
|
|
|
let u = Universe::default();
|
|
|
|
let _ = u.x;
|
|
|
|
let _ = u.y; //~ ERROR private
|
2017-10-19 16:43:47 -05:00
|
|
|
let _ = u.z; //~ ERROR private
|
2016-04-10 06:52:25 -05:00
|
|
|
u.f();
|
|
|
|
u.g(); //~ ERROR private
|
2017-10-19 16:43:47 -05:00
|
|
|
u.h(); //~ ERROR private
|
2016-04-10 06:52:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
mod pathological {
|
2019-08-05 09:50:37 -05:00
|
|
|
pub(in bad::path) mod m1 {} //~ ERROR failed to resolve: maybe a missing crate `bad`?
|
2017-03-07 17:50:13 -06:00
|
|
|
pub(in foo) mod m2 {} //~ ERROR visibilities can only be restricted to ancestor modules
|
2016-04-10 06:52:25 -05:00
|
|
|
}
|