about summary refs log tree commit diff
path: root/tests/rustdoc/inline_local
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2024-05-21 21:21:26 -0700
committerMichael Howell <michael@notriddle.com>2024-05-21 21:21:26 -0700
commitb5923a95a886588fd40fccd69f1ccca504234194 (patch)
tree1b30d1a5cb1f5f81b0ba117d37ae1750d638e80f /tests/rustdoc/inline_local
parent55bd054a21533cbaa02836b0ca125c2eaaa4b8f4 (diff)
Move tests into appropriate subdirectories
Diffstat (limited to 'tests/rustdoc/inline_local')
-rw-r--r--tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs32
-rw-r--r--tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs14
-rw-r--r--tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs125
-rw-r--r--tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs14
-rw-r--r--tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs17
-rw-r--r--tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs33
-rw-r--r--tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs16
7 files changed, 251 insertions, 0 deletions
diff --git a/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs b/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs
new file mode 100644
index 00000000000..343e030da9e
--- /dev/null
+++ b/tests/rustdoc/inline_local/blanket-impl-reexported-trait-94183.rs
@@ -0,0 +1,32 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/94183>.
+// This test ensures that a publicly re-exported private trait will
+// appear in the blanket impl list.
+
+// https://github.com/rust-lang/rust/issues/94183
+#![crate_name = "foo"]
+
+// @has 'foo/struct.S.html'
+
+mod actual_sub {
+    pub trait Actual {}
+    pub trait Another {}
+
+    // `Another` is publicly re-exported so it should appear in the blanket impl list.
+    // @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Another for T'
+    impl<T> Another for T {}
+
+    trait Foo {}
+
+    // `Foo` is not publicly re-exported nor reachable so it shouldn't appear in the
+    // blanket impl list.
+    // @!has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Foo for T'
+    impl<T> Foo for T {}
+}
+
+pub use actual_sub::{Actual, Another};
+
+// `Actual` is publicly re-exported so it should appear in the blanket impl list.
+// @has - '//*[@id="blanket-implementations-list"]//*[@class="code-header"]' 'impl<T> Actual for T'
+impl<T> Actual for T {}
+
+pub struct S;
diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs
new file mode 100644
index 00000000000..c066f54b32b
--- /dev/null
+++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141-2.rs
@@ -0,0 +1,14 @@
+//@ edition:2015
+
+// https://github.com/rust-lang/rust/issues/81141
+#![crate_name = "foo"]
+
+use external::Public as Private;
+
+pub mod external {
+    pub struct Public;
+
+    // @has 'foo/external/fn.make.html'
+    // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public'
+    pub fn make() -> ::Private { super::Private }
+}
diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs
new file mode 100644
index 00000000000..d695ed7fbfa
--- /dev/null
+++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-81141.rs
@@ -0,0 +1,125 @@
+// This test ensures that if a private re-export is present in a public API, it'll be
+// replaced by the first public item in the re-export chain or by the private item.
+
+// https://github.com/rust-lang/rust/issues/81141
+#![crate_name = "foo"]
+
+use crate::bar::Bar as Alias;
+
+pub use crate::bar::Bar as Whatever;
+use crate::Whatever as Whatever2;
+use crate::Whatever2 as Whatever3;
+pub use crate::bar::Inner as Whatever4;
+
+mod bar {
+    pub struct Bar;
+    pub use self::Bar as Inner;
+}
+
+// @has 'foo/fn.bar.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar'
+pub fn bar() -> Alias {
+    Alias
+}
+
+// @has 'foo/fn.bar2.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Whatever'
+pub fn bar2() -> Whatever3 {
+    Whatever
+}
+
+// @has 'foo/fn.bar3.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Whatever4'
+pub fn bar3() -> Whatever4 {
+    Whatever
+}
+
+// @has 'foo/fn.bar4.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar4() -> Bar'
+pub fn bar4() -> crate::Alias {
+    Alias
+}
+
+// @has 'foo/fn.bar5.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar5() -> Whatever'
+pub fn bar5() -> crate::Whatever3 {
+    Whatever
+}
+
+// @has 'foo/fn.bar6.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar6() -> Whatever4'
+pub fn bar6() -> crate::Whatever4 {
+    Whatever
+}
+
+
+// @has 'foo/fn.bar7.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar7() -> Bar'
+pub fn bar7() -> self::Alias {
+    Alias
+}
+
+// @has 'foo/fn.bar8.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar8() -> Whatever'
+pub fn bar8() -> self::Whatever3 {
+    Whatever
+}
+
+// @has 'foo/fn.bar9.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar9() -> Whatever4'
+pub fn bar9() -> self::Whatever4 {
+    Whatever
+}
+
+mod nested {
+    pub(crate) use crate::Alias;
+    pub(crate) use crate::Whatever3;
+    pub(crate) use crate::Whatever4;
+    pub(crate) use crate::nested as nested2;
+}
+
+// @has 'foo/fn.bar10.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar10() -> Bar'
+pub fn bar10() -> nested::Alias {
+    Alias
+}
+
+// @has 'foo/fn.bar11.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar11() -> Whatever'
+pub fn bar11() -> nested::Whatever3 {
+    Whatever
+}
+
+// @has 'foo/fn.bar12.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar12() -> Whatever4'
+pub fn bar12() -> nested::Whatever4 {
+    Whatever
+}
+
+// @has 'foo/fn.bar13.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar13() -> Bar'
+pub fn bar13() -> nested::nested2::Alias {
+    Alias
+}
+
+// @has 'foo/fn.bar14.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar14() -> Whatever'
+pub fn bar14() -> nested::nested2::Whatever3 {
+    Whatever
+}
+
+// @has 'foo/fn.bar15.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar15() -> Whatever4'
+pub fn bar15() -> nested::nested2::Whatever4 {
+    Whatever
+}
+
+use external::Public as Private;
+
+pub mod external {
+    pub struct Public;
+
+    // @has 'foo/external/fn.make.html'
+    // @has - '//*[@class="rust item-decl"]/code' 'pub fn make() -> Public'
+    pub fn make() -> super::Private { super::Private }
+}
diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs
new file mode 100644
index 00000000000..1c86c769a12
--- /dev/null
+++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-generics-81141.rs
@@ -0,0 +1,14 @@
+// https://github.com/rust-lang/rust/issues/81141
+#![crate_name = "foo"]
+
+use crate::bar::Foo as Alias;
+
+pub mod bar {
+    pub struct Foo<'a, T>(&'a T);
+}
+
+// @has "foo/fn.foo.html"
+// @has - '//*[@class="rust item-decl"]/code' "pub fn foo<'a, T>(f: Foo<'a, T>) -> Foo<'a, usize>"
+pub fn foo<'a, T>(f: Alias<'a, T>) -> Alias<'a, usize> {
+    Alias(&0)
+}
diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs
new file mode 100644
index 00000000000..7d6fadf26e2
--- /dev/null
+++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-hidden-81141.rs
@@ -0,0 +1,17 @@
+//@ compile-flags: -Z unstable-options --document-hidden-items
+
+// https://github.com/rust-lang/rust/issues/81141
+#![crate_name = "foo"]
+
+#[doc(hidden)]
+pub use crate::bar::Bar as Alias;
+
+mod bar {
+    pub struct Bar;
+}
+
+// @has 'foo/fn.bar.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Alias'
+pub fn bar() -> Alias {
+    Alias
+}
diff --git a/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs b/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs
new file mode 100644
index 00000000000..6bf507838d5
--- /dev/null
+++ b/tests/rustdoc/inline_local/private-reexport-in-public-api-private-81141.rs
@@ -0,0 +1,33 @@
+//@ compile-flags: --document-private-items
+
+// https://github.com/rust-lang/rust/issues/81141
+#![crate_name = "foo"]
+
+use crate::bar::Bar as Alias;
+pub(crate) use crate::bar::Bar as CrateAlias;
+
+mod bar {
+    pub struct Bar;
+    pub use self::Bar as Inner;
+}
+
+// It's a fully private re-export so it should not be displayed.
+// @has 'foo/fn.bar.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar() -> Bar'
+pub fn bar() -> Alias {
+    Alias
+}
+
+// It's public re-export inside a private module so it should be visible.
+// @has 'foo/fn.bar2.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar2() -> Inner'
+pub fn bar2() -> crate::bar::Inner {
+    Alias
+}
+
+// It's a non-public, so it doesn't appear in documentation so it should not be visible.
+// @has 'foo/fn.bar3.html'
+// @has - '//*[@class="rust item-decl"]/code' 'pub fn bar3() -> Bar'
+pub fn bar3() -> CrateAlias {
+    Alias
+}
diff --git a/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs b/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs
new file mode 100644
index 00000000000..cffe1289ce8
--- /dev/null
+++ b/tests/rustdoc/inline_local/reexported-macro-and-macro-export-sidebar-89852.rs
@@ -0,0 +1,16 @@
+//@ edition:2018
+
+// https://github.com/rust-lang/rust/issues/89852
+#![crate_name = "foo"]
+#![no_core]
+#![feature(no_core)]
+
+// @matchesraw 'foo/sidebar-items.js' '"repro"'
+// @!matchesraw 'foo/sidebar-items.js' '"repro".*"repro"'
+
+#[macro_export]
+macro_rules! repro {
+    () => {};
+}
+
+pub use crate::repro as repro2;