summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-json/reexport
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rustdoc-json/reexport')
-rw-r--r--tests/rustdoc-json/reexport/auxiliary/pub-struct.rs1
-rw-r--r--tests/rustdoc-json/reexport/auxiliary/trait_with_docs.rs2
-rw-r--r--tests/rustdoc-json/reexport/export_extern_crate_as_self.rs11
-rw-r--r--tests/rustdoc-json/reexport/glob_collision.rs28
-rw-r--r--tests/rustdoc-json/reexport/glob_empty_mod.rs8
-rw-r--r--tests/rustdoc-json/reexport/glob_extern.rs23
-rw-r--r--tests/rustdoc-json/reexport/glob_private.rs33
-rw-r--r--tests/rustdoc-json/reexport/in_root_and_mod.rs16
-rw-r--r--tests/rustdoc-json/reexport/in_root_and_mod_pub.rs20
-rw-r--r--tests/rustdoc-json/reexport/macro.rs15
-rw-r--r--tests/rustdoc-json/reexport/mod_not_included.rs14
-rw-r--r--tests/rustdoc-json/reexport/private_twice_one_inline.rs28
-rw-r--r--tests/rustdoc-json/reexport/private_two_names.rs22
-rw-r--r--tests/rustdoc-json/reexport/pub_use_doc_hidden.rs15
-rw-r--r--tests/rustdoc-json/reexport/reexport_method_from_private_module.rs28
-rw-r--r--tests/rustdoc-json/reexport/rename_private.rs13
-rw-r--r--tests/rustdoc-json/reexport/rename_public.rs17
-rw-r--r--tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs21
-rw-r--r--tests/rustdoc-json/reexport/simple_private.rs16
-rw-r--r--tests/rustdoc-json/reexport/simple_public.rs18
-rw-r--r--tests/rustdoc-json/reexport/synthesize_trait_with_docs.rs10
21 files changed, 359 insertions, 0 deletions
diff --git a/tests/rustdoc-json/reexport/auxiliary/pub-struct.rs b/tests/rustdoc-json/reexport/auxiliary/pub-struct.rs
new file mode 100644
index 000000000..4a835673a
--- /dev/null
+++ b/tests/rustdoc-json/reexport/auxiliary/pub-struct.rs
@@ -0,0 +1 @@
+pub struct Foo;
diff --git a/tests/rustdoc-json/reexport/auxiliary/trait_with_docs.rs b/tests/rustdoc-json/reexport/auxiliary/trait_with_docs.rs
new file mode 100644
index 000000000..1e87966b2
--- /dev/null
+++ b/tests/rustdoc-json/reexport/auxiliary/trait_with_docs.rs
@@ -0,0 +1,2 @@
+/// The Docs
+pub trait HasDocs {}
diff --git a/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs b/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs
new file mode 100644
index 000000000..f076feb71
--- /dev/null
+++ b/tests/rustdoc-json/reexport/export_extern_crate_as_self.rs
@@ -0,0 +1,11 @@
+//! Regression test for <https://github.com/rust-lang/rust/issues/100531>
+
+#![feature(no_core)]
+#![no_core]
+
+#![crate_name = "export_extern_crate_as_self"]
+
+// ignore-tidy-linelength
+
+// @is "$.index[*][?(@.kind=='module')].name" \"export_extern_crate_as_self\"
+pub extern crate self as export_extern_crate_as_self; // Must be the same name as the crate already has
diff --git a/tests/rustdoc-json/reexport/glob_collision.rs b/tests/rustdoc-json/reexport/glob_collision.rs
new file mode 100644
index 000000000..f91144dbf
--- /dev/null
+++ b/tests/rustdoc-json/reexport/glob_collision.rs
@@ -0,0 +1,28 @@
+// Regression test for https://github.com/rust-lang/rust/issues/100973
+
+#![feature(no_core)]
+#![no_core]
+
+// @set m1 = "$.index[*][?(@.name == 'm1' && @.kind == 'module')].id"
+// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.items" []
+// @is "$.index[*][?(@.name == 'm1' && @.kind == 'module')].inner.is_stripped" true
+mod m1 {
+ pub fn f() {}
+}
+// @set m2 = "$.index[*][?(@.name == 'm2' && @.kind == 'module')].id"
+// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.items" []
+// @is "$.index[*][?(@.name == 'm2' && @.kind == 'module')].inner.is_stripped" true
+mod m2 {
+ pub fn f(_: u8) {}
+}
+
+// @set m1_use = "$.index[*][?(@.inner.name=='m1')].id"
+// @is "$.index[*][?(@.inner.name=='m1')].inner.id" $m1
+// @is "$.index[*][?(@.inner.name=='m1')].inner.glob" true
+pub use m1::*;
+// @set m2_use = "$.index[*][?(@.inner.name=='m2')].id"
+// @is "$.index[*][?(@.inner.name=='m2')].inner.id" $m2
+// @is "$.index[*][?(@.inner.name=='m2')].inner.glob" true
+pub use m2::*;
+
+// @ismany "$.index[*][?(@.inner.is_crate==true)].inner.items[*]" $m1_use $m2_use
diff --git a/tests/rustdoc-json/reexport/glob_empty_mod.rs b/tests/rustdoc-json/reexport/glob_empty_mod.rs
new file mode 100644
index 000000000..da6822835
--- /dev/null
+++ b/tests/rustdoc-json/reexport/glob_empty_mod.rs
@@ -0,0 +1,8 @@
+// Regression test for https://github.com/rust-lang/rust/issues/100973
+
+// @is "$.index[*][?(@.name=='m1' && @.kind == 'module')].inner.is_stripped" true
+// @set m1 = "$.index[*][?(@.name=='m1')].id"
+mod m1 {}
+
+// @is "$.index[*][?(@.inner.name=='m1' && @.kind=='import')].inner.id" $m1
+pub use m1::*;
diff --git a/tests/rustdoc-json/reexport/glob_extern.rs b/tests/rustdoc-json/reexport/glob_extern.rs
new file mode 100644
index 000000000..7a1e8c11f
--- /dev/null
+++ b/tests/rustdoc-json/reexport/glob_extern.rs
@@ -0,0 +1,23 @@
+// edition:2018
+
+#![no_core]
+#![feature(no_core)]
+
+// @is "$.index[*][?(@.name=='mod1')].kind" \"module\"
+// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true"
+mod mod1 {
+ extern "C" {
+ // @set public_fn_id = "$.index[*][?(@.name=='public_fn')].id"
+ pub fn public_fn();
+ // @!has "$.index[*][?(@.name=='private_fn')]"
+ fn private_fn();
+ }
+ // @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $public_fn_id
+ // @set mod1_id = "$.index[*][?(@.name=='mod1')].id"
+}
+
+// @is "$.index[*][?(@.kind=='import')].inner.glob" true
+// @is "$.index[*][?(@.kind=='import')].inner.id" $mod1_id
+// @set use_id = "$.index[*][?(@.kind=='import')].id"
+// @ismany "$.index[*][?(@.name=='glob_extern')].inner.items[*]" $use_id
+pub use mod1::*;
diff --git a/tests/rustdoc-json/reexport/glob_private.rs b/tests/rustdoc-json/reexport/glob_private.rs
new file mode 100644
index 000000000..3a83a2081
--- /dev/null
+++ b/tests/rustdoc-json/reexport/glob_private.rs
@@ -0,0 +1,33 @@
+// edition:2018
+
+#![no_core]
+#![feature(no_core)]
+
+// @is "$.index[*][?(@.name=='mod1')].kind" \"module\"
+// @is "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true"
+mod mod1 {
+ // @is "$.index[*][?(@.name=='mod2')].kind" \"module\"
+ // @is "$.index[*][?(@.name=='mod2')].inner.is_stripped" "true"
+ mod mod2 {
+ // @set m2pub_id = "$.index[*][?(@.name=='Mod2Public')].id"
+ pub struct Mod2Public;
+
+ // @!has "$.index[*][?(@.name=='Mod2Private')]"
+ struct Mod2Private;
+ }
+
+ // @set mod2_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')].id"
+ pub use self::mod2::*;
+
+ // @set m1pub_id = "$.index[*][?(@.name=='Mod1Public')].id"
+ pub struct Mod1Public;
+ // @!has "$.index[*][?(@.name=='Mod1Private')]"
+ struct Mod1Private;
+}
+
+// @set mod1_use_id = "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')].id"
+pub use mod1::*;
+
+// @ismany "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id
+// @ismany "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id $mod2_use_id
+// @ismany "$.index[*][?(@.name=='glob_private')].inner.items[*]" $mod1_use_id
diff --git a/tests/rustdoc-json/reexport/in_root_and_mod.rs b/tests/rustdoc-json/reexport/in_root_and_mod.rs
new file mode 100644
index 000000000..7b97ebf21
--- /dev/null
+++ b/tests/rustdoc-json/reexport/in_root_and_mod.rs
@@ -0,0 +1,16 @@
+#![feature(no_core)]
+#![no_core]
+
+// @!has "$.index[*][?(@.name=='foo')]"
+mod foo {
+ // @has "$.index[*][?(@.name=='Foo')]"
+ pub struct Foo;
+}
+
+// @has "$.index[*][?(@.kind=='import' && @.inner.source=='foo::Foo')]"
+pub use foo::Foo;
+
+pub mod bar {
+ // @has "$.index[*][?(@.kind=='import' && @.inner.source=='crate::foo::Foo')]"
+ pub use crate::foo::Foo;
+}
diff --git a/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs b/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs
new file mode 100644
index 000000000..f6d932d92
--- /dev/null
+++ b/tests/rustdoc-json/reexport/in_root_and_mod_pub.rs
@@ -0,0 +1,20 @@
+#![feature(no_core)]
+#![no_core]
+
+pub mod foo {
+ // @set bar_id = "$.index[*][?(@.name=='Bar')].id"
+ // @ismany "$.index[*][?(@.name=='foo')].inner.items[*]" $bar_id
+ pub struct Bar;
+}
+
+// @set root_import_id = "$.index[*][?(@.inner.source=='foo::Bar')].id"
+// @is "$.index[*][?(@.inner.source=='foo::Bar')].inner.id" $bar_id
+// @has "$.index[*][?(@.name=='in_root_and_mod_pub')].inner.items[*]" $root_import_id
+pub use foo::Bar;
+
+pub mod baz {
+ // @set baz_import_id = "$.index[*][?(@.inner.source=='crate::foo::Bar')].id"
+ // @is "$.index[*][?(@.inner.source=='crate::foo::Bar')].inner.id" $bar_id
+ // @ismany "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id
+ pub use crate::foo::Bar;
+}
diff --git a/tests/rustdoc-json/reexport/macro.rs b/tests/rustdoc-json/reexport/macro.rs
new file mode 100644
index 000000000..b4882100f
--- /dev/null
+++ b/tests/rustdoc-json/reexport/macro.rs
@@ -0,0 +1,15 @@
+// edition:2018
+
+#![no_core]
+#![feature(no_core)]
+
+// @set repro_id = "$.index[*][?(@.name=='repro')].id"
+#[macro_export]
+macro_rules! repro {
+ () => {};
+}
+
+// @set repro2_id = "$.index[*][?(@.inner.name=='repro2')].id"
+pub use crate::repro as repro2;
+
+// @ismany "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id $repro2_id
diff --git a/tests/rustdoc-json/reexport/mod_not_included.rs b/tests/rustdoc-json/reexport/mod_not_included.rs
new file mode 100644
index 000000000..7b7600ef2
--- /dev/null
+++ b/tests/rustdoc-json/reexport/mod_not_included.rs
@@ -0,0 +1,14 @@
+// Regression test for https://github.com/rust-lang/rust/issues/101103
+
+#![feature(no_core)]
+#![no_core]
+
+mod m1 {
+ pub fn x() {}
+}
+
+pub use m1::x;
+
+// @has "$.index[*][?(@.name=='x' && @.kind=='function')]"
+// @has "$.index[*][?(@.kind=='import' && @.inner.name=='x')].inner.source" '"m1::x"'
+// @!has "$.index[*][?(@.name=='m1')]"
diff --git a/tests/rustdoc-json/reexport/private_twice_one_inline.rs b/tests/rustdoc-json/reexport/private_twice_one_inline.rs
new file mode 100644
index 000000000..687a3b2ac
--- /dev/null
+++ b/tests/rustdoc-json/reexport/private_twice_one_inline.rs
@@ -0,0 +1,28 @@
+// aux-build:pub-struct.rs
+// ignore-tidy-linelength
+
+// Test for the ICE in https://github.com/rust-lang/rust/issues/83057
+// An external type re-exported with different attributes shouldn't cause an error
+
+#![no_core]
+#![feature(no_core)]
+
+extern crate pub_struct as foo;
+#[doc(inline)]
+
+// @set crate_use_id = "$.index[*][?(@.docs=='Hack A')].id"
+// @set foo_id = "$.index[*][?(@.docs=='Hack A')].inner.id"
+/// Hack A
+pub use foo::Foo;
+
+// @set bar_id = "$.index[*][?(@.name=='bar')].id"
+pub mod bar {
+ // @is "$.index[*][?(@.docs=='Hack B')].inner.id" $foo_id
+ // @set bar_use_id = "$.index[*][?(@.docs=='Hack B')].id"
+ // @ismany "$.index[*][?(@.name=='bar')].inner.items[*]" $bar_use_id
+ /// Hack B
+ pub use foo::Foo;
+}
+
+// @ismany "$.index[*][?(@.kind=='import')].id" $crate_use_id $bar_use_id
+// @ismany "$.index[*][?(@.name=='private_twice_one_inline')].inner.items[*]" $bar_id $crate_use_id
diff --git a/tests/rustdoc-json/reexport/private_two_names.rs b/tests/rustdoc-json/reexport/private_two_names.rs
new file mode 100644
index 000000000..9858538a9
--- /dev/null
+++ b/tests/rustdoc-json/reexport/private_two_names.rs
@@ -0,0 +1,22 @@
+// ignore-tidy-linelength
+
+// Test for the ICE in https://github.com/rust-lang/rust/issues/83720
+// A pub-in-private type re-exported under two different names shouldn't cause an error
+
+#![no_core]
+#![feature(no_core)]
+
+// @!has "$.index[*][?(@.name=='style')]"
+mod style {
+ // @set color_struct_id = "$.index[*][?(@.kind=='struct' && @.name=='Color')].id"
+ pub struct Color;
+}
+
+// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].inner.id" $color_struct_id
+// @set color_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Color')].id"
+pub use style::Color;
+// @is "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].inner.id" $color_struct_id
+// @set colour_export_id = "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')].id"
+pub use style::Color as Colour;
+
+// @ismany "$.index[*][?(@.name=='private_two_names')].inner.items[*]" $color_export_id $colour_export_id
diff --git a/tests/rustdoc-json/reexport/pub_use_doc_hidden.rs b/tests/rustdoc-json/reexport/pub_use_doc_hidden.rs
new file mode 100644
index 000000000..a2a25d084
--- /dev/null
+++ b/tests/rustdoc-json/reexport/pub_use_doc_hidden.rs
@@ -0,0 +1,15 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/106379>
+
+#![feature(no_core)]
+#![no_core]
+
+mod repeat_n {
+ #[doc(hidden)]
+ pub struct RepeatN {}
+}
+
+pub use repeat_n::RepeatN;
+
+// @count "$.index[*][?(@.name=='pub_use_doc_hidden')].inner.items[*]" 0
+// @!has "$.index[*][?(@.kind=='struct')]"
+// @!has "$.index[*][?(@.kind=='import')]"
diff --git a/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs b/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs
new file mode 100644
index 000000000..239b1a23b
--- /dev/null
+++ b/tests/rustdoc-json/reexport/reexport_method_from_private_module.rs
@@ -0,0 +1,28 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/102583>.
+
+// @set impl_S = "$.index[*][?(@.docs=='impl S')].id"
+// @has "$.index[*][?(@.name=='S')].inner.impls[*]" $impl_S
+// @set is_present = "$.index[*][?(@.name=='is_present')].id"
+// @is "$.index[*][?(@.docs=='impl S')].inner.items[*]" $is_present
+// @!has "$.index[*][?(@.name=='hidden_impl')]"
+// @!has "$.index[*][?(@.name=='hidden_fn')]"
+
+#![no_std]
+
+mod private_mod {
+ pub struct S;
+
+ /// impl S
+ impl S {
+ pub fn is_present() {}
+ #[doc(hidden)]
+ pub fn hidden_fn() {}
+ }
+
+ #[doc(hidden)]
+ impl S {
+ pub fn hidden_impl() {}
+ }
+}
+
+pub use private_mod::*;
diff --git a/tests/rustdoc-json/reexport/rename_private.rs b/tests/rustdoc-json/reexport/rename_private.rs
new file mode 100644
index 000000000..8fd850f9b
--- /dev/null
+++ b/tests/rustdoc-json/reexport/rename_private.rs
@@ -0,0 +1,13 @@
+// edition:2018
+
+#![no_core]
+#![feature(no_core)]
+
+// @!has "$.index[*][?(@.kind=='inner')]"
+mod inner {
+ // @has "$.index[*][?(@.name=='Public')]"
+ pub struct Public;
+}
+
+// @is "$.index[*][?(@.kind=='import')].inner.name" \"NewName\"
+pub use inner::Public as NewName;
diff --git a/tests/rustdoc-json/reexport/rename_public.rs b/tests/rustdoc-json/reexport/rename_public.rs
new file mode 100644
index 000000000..e30907fe2
--- /dev/null
+++ b/tests/rustdoc-json/reexport/rename_public.rs
@@ -0,0 +1,17 @@
+// edition:2018
+
+#![no_core]
+#![feature(no_core)]
+
+// @set inner_id = "$.index[*][?(@.name=='inner')].id"
+pub mod inner {
+ // @set public_id = "$.index[*][?(@.name=='Public')].id"
+ // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id
+ pub struct Public;
+}
+// @set import_id = "$.index[*][?(@.inner.name=='NewName')].id"
+// @!has "$.index[*][?(@.inner.name=='Public')]"
+// @is "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\"
+pub use inner::Public as NewName;
+
+// @ismany "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id $import_id
diff --git a/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs b/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs
new file mode 100644
index 000000000..880dbdc44
--- /dev/null
+++ b/tests/rustdoc-json/reexport/same_type_reexported_more_than_once.rs
@@ -0,0 +1,21 @@
+// ignore-tidy-linelength
+
+// Regression test for <https://github.com/rust-lang/rust/issues/97432>.
+
+#![feature(no_core)]
+#![no_std]
+#![no_core]
+
+mod inner {
+ // @set trait_id = "$.index[*][?(@.name=='Trait')].id"
+ pub trait Trait {}
+}
+
+// @set export_id = "$.index[*][?(@.inner.name=='Trait')].id"
+// @is "$.index[*][?(@.inner.name=='Trait')].inner.id" $trait_id
+pub use inner::Trait;
+// @set reexport_id = "$.index[*][?(@.inner.name=='Reexport')].id"
+// @is "$.index[*][?(@.inner.name=='Reexport')].inner.id" $trait_id
+pub use inner::Trait as Reexport;
+
+// @ismany "$.index[*][?(@.name=='same_type_reexported_more_than_once')].inner.items[*]" $reexport_id $export_id
diff --git a/tests/rustdoc-json/reexport/simple_private.rs b/tests/rustdoc-json/reexport/simple_private.rs
new file mode 100644
index 000000000..d058ce059
--- /dev/null
+++ b/tests/rustdoc-json/reexport/simple_private.rs
@@ -0,0 +1,16 @@
+// edition:2018
+#![no_core]
+#![feature(no_core)]
+
+// @!has "$.index[*][?(@.name=='inner')]"
+mod inner {
+ // @set pub_id = "$.index[*][?(@.name=='Public')].id"
+ pub struct Public;
+}
+
+// @is "$.index[*][?(@.kind=='import')].inner.name" \"Public\"
+// @is "$.index[*][?(@.kind=='import')].inner.id" $pub_id
+// @set use_id = "$.index[*][?(@.kind=='import')].id"
+pub use inner::Public;
+
+// @ismany "$.index[*][?(@.name=='simple_private')].inner.items[*]" $use_id
diff --git a/tests/rustdoc-json/reexport/simple_public.rs b/tests/rustdoc-json/reexport/simple_public.rs
new file mode 100644
index 000000000..e64a0dcb7
--- /dev/null
+++ b/tests/rustdoc-json/reexport/simple_public.rs
@@ -0,0 +1,18 @@
+// edition:2018
+
+#![no_core]
+#![feature(no_core)]
+
+// @set inner_id = "$.index[*][?(@.name=='inner')].id"
+pub mod inner {
+
+ // @set public_id = "$.index[*][?(@.name=='Public')].id"
+ // @ismany "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id
+ pub struct Public;
+}
+
+// @set import_id = "$.index[*][?(@.inner.name=='Public')].id"
+// @is "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\"
+pub use inner::Public;
+
+// @ismany "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id $inner_id
diff --git a/tests/rustdoc-json/reexport/synthesize_trait_with_docs.rs b/tests/rustdoc-json/reexport/synthesize_trait_with_docs.rs
new file mode 100644
index 000000000..25a7c08d6
--- /dev/null
+++ b/tests/rustdoc-json/reexport/synthesize_trait_with_docs.rs
@@ -0,0 +1,10 @@
+// Regression test for <https://github.com/rust-lang/rust/issues/105022>
+// aux-build: trait_with_docs.rs
+
+extern crate trait_with_docs;
+
+pub struct Local;
+
+impl trait_with_docs::HasDocs for Local {}
+
+// @!has "$.index[*][?(@.name == 'HasDocs')]"