about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs5
-rw-r--r--tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr16
-rw-r--r--tests/rustdoc/issue-110422-inner-private.rs64
3 files changed, 68 insertions, 17 deletions
diff --git a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs b/tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs
index ac517257498..096130d7768 100644
--- a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs
+++ b/tests/rustdoc-ui/infinite-recursive-type-impl-trait.rs
@@ -1,6 +1,9 @@
+// check-pass
+
 fn f() -> impl Sized {
-    enum E { //~ ERROR
+    enum E {
         V(E),
     }
+
     unimplemented!()
 }
diff --git a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr b/tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr
deleted file mode 100644
index a61577bd14a..00000000000
--- a/tests/rustdoc-ui/infinite-recursive-type-impl-trait.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error[E0072]: recursive type `f::E` has infinite size
-  --> $DIR/infinite-recursive-type-impl-trait.rs:2:5
-   |
-LL |     enum E {
-   |     ^^^^^^
-LL |         V(E),
-   |           - recursive without indirection
-   |
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
-   |
-LL |         V(Box<E>),
-   |           ++++ +
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0072`.
diff --git a/tests/rustdoc/issue-110422-inner-private.rs b/tests/rustdoc/issue-110422-inner-private.rs
new file mode 100644
index 00000000000..ee8ed5cc6e1
--- /dev/null
+++ b/tests/rustdoc/issue-110422-inner-private.rs
@@ -0,0 +1,64 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/110422>.
+// This test ensures that inner items (except for implementations and macros)
+// don't appear in documentation.
+
+// compile-flags: --document-private-items
+
+#![crate_name = "foo"]
+
+// @has 'foo/index.html'
+// Checking there is no "trait" entry.
+// @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 4
+// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Structs'
+// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Constants'
+// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Functions'
+// @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Macros'
+
+// @has - '//a[@href="fn.foo.html"]' 'foo'
+fn foo() {
+    fn bar() {}
+
+    // @has - '//a[@class="macro"]' 'visible_macro'
+    // @!has - '//a[@class="macro"]' 'non_visible_macro'
+    // @has 'foo/macro.visible_macro.html'
+    // @!has 'foo/macro.non_visible_macro.html'
+    #[macro_export]
+    macro_rules! visible_macro {
+        () => {}
+    }
+
+    macro_rules! non_visible_macro {
+        () => {}
+    }
+}
+
+// @has 'foo/index.html'
+// @has - '//a[@href="struct.Bar.html"]' 'Bar'
+struct Bar;
+
+const BAR: i32 = {
+    // @!has - '//a[@href="fn.yo.html"]' 'yo'
+    // @!has 'foo/fn.yo.html'
+    fn yo() {}
+
+    // @!has 'foo/index.html' '//a[@href="trait.Foo.html"]' 'Foo'
+    // @!has 'foo/trait.Foo.html'
+    trait Foo {
+        fn babar() {}
+    }
+    impl Foo for Bar {}
+
+    // @has 'foo/struct.Bar.html'
+    // @has - '//*[@id="method.foo"]/*[@class="code-header"]' 'pub(crate) fn foo()'
+    // @count - '//*[@id="main-content"]/*[@class="small-section-header"]' 3
+    // We now check that the `Foo` trait is not documented nor visible on `Bar` page.
+    // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Implementations'
+    // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Auto Trait Implementations'
+    // @has - '//*[@id="main-content"]/*[@class="small-section-header"]' 'Blanket Implementations'
+    // @!has - '//*[@href="trait.Foo.html#method.babar"]/*[@class="code-header"]' 'fn babar()'
+    impl Bar {
+        fn foo() {}
+    }
+
+    1
+};