]> git.lizzy.rs Git - rust.git/blob - tests/rustdoc/glob-shadowing.rs
Rollup merge of #107412 - tshepang:needless-check, r=wesleywiser
[rust.git] / tests / rustdoc / glob-shadowing.rs
1 // @has 'glob_shadowing/index.html'
2 // @count - '//div[@class="item-left"]' 6
3 // @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe'
4 // @has - '//div[@class="item-right docblock-short"]' 'sub2::describe'
5
6 // @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe2'
7
8 // @!has - '//div[@class="item-right docblock-short"]' 'sub1::prelude'
9 // @has - '//div[@class="item-right docblock-short"]' 'mod::prelude'
10
11 // @has - '//div[@class="item-right docblock-short"]' 'sub1::Foo (struct)'
12 // @has - '//div[@class="item-right docblock-short"]' 'mod::Foo (function)'
13
14 // @has - '//div[@class="item-right docblock-short"]' 'sub4::inner::X'
15
16 // @has 'glob_shadowing/fn.describe.html'
17 // @has - '//div[@class="docblock"]' 'sub2::describe'
18
19 mod sub1 {
20     // this should be shadowed by sub2::describe
21     /// sub1::describe
22     pub fn describe() -> &'static str {
23         "sub1::describe"
24     }
25
26     // this should be shadowed by mod::prelude
27     /// sub1::prelude
28     pub mod prelude {
29     }
30
31     // this should *not* be shadowed, because sub1::Foo and mod::Foo are in different namespaces
32     /// sub1::Foo (struct)
33     pub struct Foo;
34
35     // this should be shadowed,
36     // because both sub1::describe2 and sub3::describe2 are from glob reexport
37     /// sub1::describe2
38     pub fn describe2() -> &'static str {
39         "sub1::describe2"
40     }
41 }
42
43 mod sub2 {
44     /// sub2::describe
45     pub fn describe() -> &'static str {
46         "sub2::describe"
47     }
48 }
49
50 mod sub3 {
51     // this should be shadowed
52     // because both sub1::describe2 and sub3::describe2 are from glob reexport
53     /// sub3::describe2
54     pub fn describe2() -> &'static str {
55         "sub3::describe2"
56     }
57 }
58
59 mod sub4 {
60     // this should be shadowed by sub4::inner::X
61     /// sub4::X
62     pub const X: usize = 0;
63     pub mod inner {
64         pub use super::*;
65         /// sub4::inner::X
66         pub const X: usize = 1;
67     }
68 }
69
70 /// mod::Foo (function)
71 pub fn Foo() {}
72
73 #[doc(inline)]
74 pub use sub2::describe;
75
76 #[doc(inline)]
77 pub use sub1::*;
78
79 #[doc(inline)]
80 pub use sub3::*;
81
82 #[doc(inline)]
83 pub use sub4::inner::*;
84
85 /// mod::prelude
86 pub mod prelude {}