summaryrefslogtreecommitdiffstats
path: root/src/test/rustdoc/glob-shadowing.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:03:36 +0000
commit17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch)
tree3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/test/rustdoc/glob-shadowing.rs
parentAdding upstream version 1.64.0+dfsg1. (diff)
downloadrustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.tar.xz
rustc-f7f0cc2a5d72e2c61c1f6900e70eec992bea4273.zip
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/rustdoc/glob-shadowing.rs')
-rw-r--r--src/test/rustdoc/glob-shadowing.rs86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/test/rustdoc/glob-shadowing.rs b/src/test/rustdoc/glob-shadowing.rs
new file mode 100644
index 000000000..66a31c42b
--- /dev/null
+++ b/src/test/rustdoc/glob-shadowing.rs
@@ -0,0 +1,86 @@
+// @has 'glob_shadowing/index.html'
+// @count - '//div[@class="item-left module-item"]' 6
+// @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe'
+// @has - '//div[@class="item-right docblock-short"]' 'sub2::describe'
+
+// @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe2'
+
+// @!has - '//div[@class="item-right docblock-short"]' 'sub1::prelude'
+// @has - '//div[@class="item-right docblock-short"]' 'mod::prelude'
+
+// @has - '//div[@class="item-right docblock-short"]' 'sub1::Foo (struct)'
+// @has - '//div[@class="item-right docblock-short"]' 'mod::Foo (function)'
+
+// @has - '//div[@class="item-right docblock-short"]' 'sub4::inner::X'
+
+// @has 'glob_shadowing/fn.describe.html'
+// @has - '//div[@class="docblock"]' 'sub2::describe'
+
+mod sub1 {
+ // this should be shadowed by sub2::describe
+ /// sub1::describe
+ pub fn describe() -> &'static str {
+ "sub1::describe"
+ }
+
+ // this should be shadowed by mod::prelude
+ /// sub1::prelude
+ pub mod prelude {
+ }
+
+ // this should *not* be shadowed, because sub1::Foo and mod::Foo are in different namespaces
+ /// sub1::Foo (struct)
+ pub struct Foo;
+
+ // this should be shadowed,
+ // because both sub1::describe2 and sub3::describe2 are from glob reexport
+ /// sub1::describe2
+ pub fn describe2() -> &'static str {
+ "sub1::describe2"
+ }
+}
+
+mod sub2 {
+ /// sub2::describe
+ pub fn describe() -> &'static str {
+ "sub2::describe"
+ }
+}
+
+mod sub3 {
+ // this should be shadowed
+ // because both sub1::describe2 and sub3::describe2 are from glob reexport
+ /// sub3::describe2
+ pub fn describe2() -> &'static str {
+ "sub3::describe2"
+ }
+}
+
+mod sub4 {
+ // this should be shadowed by sub4::inner::X
+ /// sub4::X
+ pub const X: usize = 0;
+ pub mod inner {
+ pub use super::*;
+ /// sub4::inner::X
+ pub const X: usize = 1;
+ }
+}
+
+/// mod::Foo (function)
+pub fn Foo() {}
+
+#[doc(inline)]
+pub use sub2::describe;
+
+#[doc(inline)]
+pub use sub1::*;
+
+#[doc(inline)]
+pub use sub3::*;
+
+#[doc(inline)]
+pub use sub4::inner::*;
+
+/// mod::prelude
+pub mod prelude {}