Skip to content

Commit c1aea94

Browse files
committed
rustdoc: test cases for glob shadowing
1 parent 56e9ec5 commit c1aea94

3 files changed

+103
-0
lines changed

src/test/rustdoc/glob-shadowing.rs

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// @has 'glob_shadowing/index.html'
2+
// @count - '//div[@class="item-left module-item"]' 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 {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#![crate_name = "foo"]
2+
3+
pub mod sub {
4+
pub struct Item;
5+
6+
pub mod prelude {
7+
pub use super::Item;
8+
}
9+
}
10+
11+
#[doc(inline)]
12+
pub use sub::*;
13+
14+
// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1
15+
// @count foo/prelude/index.html '//div[@class="item-row"]' 0
16+
pub mod prelude {}

src/test/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod sub {
99
}
1010

1111
// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1
12+
// @count foo/prelude/index.html '//div[@class="item-row"]' 0
1213
pub mod prelude {}
1314

1415
#[doc(inline)]

0 commit comments

Comments
 (0)