summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc/visibility.rs
blob: 4f9b06fd7a20763c16cb040efb820d55ee659120 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// compile-flags: --document-private-items

#![crate_name = "foo"]
#![feature(inherent_associated_types)]
#![allow(incomplete_features)]

// @!has 'foo/index.html' '//a[@href="struct.FooPublic.html"]/..' 'FooPublic 🔒'
// @has 'foo/struct.FooPublic.html' '//pre' 'pub struct FooPublic'
pub struct FooPublic;
// @has 'foo/index.html' '//a[@href="struct.FooJustCrate.html"]/..' 'FooJustCrate 🔒'
// @has 'foo/struct.FooJustCrate.html' '//pre' 'pub(crate) struct FooJustCrate'
pub(crate) struct FooJustCrate;
// @has 'foo/index.html' '//a[@href="struct.FooPubCrate.html"]/..' 'FooPubCrate 🔒'
// @has 'foo/struct.FooPubCrate.html' '//pre' 'pub(crate) struct FooPubCrate'
pub(crate) struct FooPubCrate;
// @has 'foo/index.html' '//a[@href="struct.FooSelf.html"]/..' 'FooSelf 🔒'
// @has 'foo/struct.FooSelf.html' '//pre' 'pub(crate) struct FooSelf'
pub(self) struct FooSelf;
// @has 'foo/index.html' '//a[@href="struct.FooInSelf.html"]/..' 'FooInSelf 🔒'
// @has 'foo/struct.FooInSelf.html' '//pre' 'pub(crate) struct FooInSelf'
pub(in self) struct FooInSelf;
// @has 'foo/index.html' '//a[@href="struct.FooPriv.html"]/..' 'FooPriv 🔒'
// @has 'foo/struct.FooPriv.html' '//pre' 'pub(crate) struct FooPriv'
struct FooPriv;

// @!has 'foo/index.html' '//a[@href="pub_mod/index.html"]/..' 'pub_mod 🔒'
pub mod pub_mod {}

// @has 'foo/index.html' '//a[@href="pub_crate_mod/index.html"]/..' 'pub_crate_mod 🔒'
pub(crate) mod pub_crate_mod {}

// @has 'foo/index.html' '//a[@href="a/index.html"]/..' 'a 🔒'
mod a {
    // @has 'foo/a/index.html' '//a[@href="struct.FooASuper.html"]/..' 'FooASuper 🔒'
    // @has 'foo/a/struct.FooASuper.html' '//pre' 'pub(crate) struct FooASuper'
    pub(super) struct FooASuper;
    // @has 'foo/a/index.html' '//a[@href="struct.FooAInSuper.html"]/..' 'FooAInSuper 🔒'
    // @has 'foo/a/struct.FooAInSuper.html' '//pre' 'pub(crate) struct FooAInSuper'
    pub(in super) struct FooAInSuper;
    // @has 'foo/a/index.html' '//a[@href="struct.FooAInA.html"]/..' 'FooAInA 🔒'
    // @has 'foo/a/struct.FooAInA.html' '//pre' 'struct FooAInA'
    // @!has 'foo/a/struct.FooAInA.html' '//pre' 'pub'
    pub(in a) struct FooAInA;
    // @has 'foo/a/index.html' '//a[@href="struct.FooAPriv.html"]/..' 'FooAPriv 🔒'
    // @has 'foo/a/struct.FooAPriv.html' '//pre' 'struct FooAPriv'
    // @!has 'foo/a/struct.FooAPriv.html' '//pre' 'pub'
    struct FooAPriv;

    // @has 'foo/a/index.html' '//a[@href="b/index.html"]/..' 'b 🔒'
    mod b {
        // @has 'foo/a/b/index.html' '//a[@href="struct.FooBSuper.html"]/..' 'FooBSuper 🔒'
        // @has 'foo/a/b/struct.FooBSuper.html' '//pre' 'pub(super) struct FooBSuper'
        pub(super) struct FooBSuper;
        // @has 'foo/a/b/index.html' '//a[@href="struct.FooBInSuperSuper.html"]/..' 'FooBInSuperSuper 🔒'
        // @has 'foo/a/b/struct.FooBInSuperSuper.html' '//pre' 'pub(crate) struct FooBInSuperSuper'
        pub(in super::super) struct FooBInSuperSuper;
        // @has 'foo/a/b/index.html' '//a[@href="struct.FooBInAB.html"]/..' 'FooBInAB 🔒'
        // @has 'foo/a/b/struct.FooBInAB.html' '//pre' 'struct FooBInAB'
        // @!has 'foo/a/b/struct.FooBInAB.html' '//pre' 'pub'
        pub(in a::b) struct FooBInAB;
        // @has 'foo/a/b/index.html' '//a[@href="struct.FooBPriv.html"]/..' 'FooBPriv 🔒'
        // @has 'foo/a/b/struct.FooBPriv.html' '//pre' 'struct FooBPriv'
        // @!has 'foo/a/b/struct.FooBPriv.html' '//pre' 'pub'
        struct FooBPriv;

        // @!has 'foo/a/b/index.html' '//a[@href="struct.FooBPub.html"]/..' 'FooBPub 🔒'
        // @has 'foo/a/b/struct.FooBPub.html' '//pre' 'pub struct FooBPub'
        pub struct FooBPub;
    }
}

// @has 'foo/trait.PubTrait.html' '//pre' 'pub trait PubTrait'
//
// @has 'foo/trait.PubTrait.html' '//pre' 'type Type;'
// @!has 'foo/trait.PubTrait.html' '//pre' 'pub type Type;'
//
// @has 'foo/trait.PubTrait.html' '//pre' 'const CONST: usize;'
// @!has 'foo/trait.PubTrait.html' '//pre' 'pub const CONST: usize;'
//
// @has 'foo/trait.PubTrait.html' '//pre' 'fn function();'
// @!has 'foo/trait.PubTrait.html' '//pre' 'pub fn function();'
//
// @!has 'foo/index.html' '//a[@href="trait.PubTrait.html"]/..' 'PubTrait 🔒'

pub trait PubTrait {
    type Type;
    const CONST: usize;
    fn function();
}

// @has 'foo/index.html' '//a[@href="trait.PrivTrait.html"]/..' 'PrivTrait 🔒'
trait PrivTrait {}

// @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'type Type'
// @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub type Type'
//
// @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'const CONST: usize'
// @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub const CONST: usize'
//
// @has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'fn function()'
// @!has 'foo/struct.FooPublic.html' '//h4[@class="code-header"]' 'pub fn function()'

impl PubTrait for FooPublic {
    type Type = usize;
    const CONST: usize = 0;
    fn function() {}
}

pub struct Assoc;

// @has foo/struct.Assoc.html
impl Assoc {
    // @has - '//*[@id="associatedtype.TypePub"]' 'pub type TypePub'
    pub type TypePub = usize;

    // @has - '//*[@id="associatedtype.TypePriv"]' 'pub(crate) type TypePriv'
    type TypePriv = usize;

    // @has - '//*[@id="associatedconstant.CONST_PUB"]' 'pub const CONST_PUB'
    pub const CONST_PUB: usize = 0;

    // @has - '//*[@id="associatedconstant.CONST_PRIV"]' 'pub(crate) const CONST_PRIV'
    const CONST_PRIV: usize = 0;

    // @has - '//*[@id="method.function_pub"]' 'pub fn function_pub()'
    pub fn function_pub() {}

    // @has - '//*[@id="method.function_priv"]' 'pub(crate) fn function_priv()'
    fn function_priv() {}
}