about summary refs log tree commit diff
path: root/src/test/rustdoc-json
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-08-15 20:11:33 +0200
committerGitHub <noreply@github.com>2022-08-15 20:11:33 +0200
commit13ff45d5528b1ab5af0ebc76efdf06baaa458dfa (patch)
tree87b6064c25c39a828479dc26aeebd751050225f7 /src/test/rustdoc-json
parent710bd23df1d4b9e87a0ea15bb51ca9de8c4eea4e (diff)
parent44b489f27a92e7e9662f27bcebb66662f4772247 (diff)
downloadrust-13ff45d5528b1ab5af0ebc76efdf06baaa458dfa.tar.gz
rust-13ff45d5528b1ab5af0ebc76efdf06baaa458dfa.zip
Rollup merge of #100325 - aDotInTheVoid:rdj-import-impl, r=GuillaumeGomez
Rustdoc-Json: Don't remove impls for items imported from private modules

After #99287, items in private modules may still be in the json output, if a public import accesses them. To reflect this, items that are imported need to be marked as retained in the `Stripper` pass, so their impls arn't removed by `ImplStripper`.

[More context on zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/Populating.20cache.2Eimpls), thanks to @ jyn514 for helping debug this.

``@rustbot`` modify labels: +A-rustdoc-json +T-rustdoc

r? ``@GuillaumeGomez``

Fixes #100252
Fixes #100242
Diffstat (limited to 'src/test/rustdoc-json')
-rw-r--r--src/test/rustdoc-json/impls/import_from_private.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/rustdoc-json/impls/import_from_private.rs b/src/test/rustdoc-json/impls/import_from_private.rs
new file mode 100644
index 00000000000..ef4d8aa39f8
--- /dev/null
+++ b/src/test/rustdoc-json/impls/import_from_private.rs
@@ -0,0 +1,24 @@
+// https://github.com/rust-lang/rust/issues/100252
+
+#![feature(no_core)]
+#![no_core]
+
+mod bar {
+    // @set baz = import_from_private.json "$.index[*][?(@.kind=='struct')].id"
+    pub struct Baz;
+    // @set impl = - "$.index[*][?(@.kind=='impl')].id"
+    impl Baz {
+        // @set doit = - "$.index[*][?(@.kind=='method')].id"
+        pub fn doit() {}
+    }
+}
+
+// @set import = - "$.index[*][?(@.kind=='import')].id"
+pub use bar::Baz;
+
+// FIXME(adotinthevoid): Use hasexact once #99474 lands
+
+// @has - "$.index[*][?(@.kind=='module')].inner.items[*]" $import
+// @is  - "$.index[*][?(@.kind=='import')].inner.id" $baz
+// @has - "$.index[*][?(@.kind=='struct')].inner.impls[*]" $impl
+// @has - "$.index[*][?(@.kind=='impl')].inner.items[*]" $doit