diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/test/rustdoc-json/reexport | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/test/rustdoc-json/reexport/auxiliary/pub-struct.rs | 1 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/glob_extern.rs | 18 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/glob_private.rs | 32 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/in_root_and_mod.rs | 17 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs | 20 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/macro.rs | 17 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/private_twice_one_inline.rs | 18 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/private_two_names.rs | 17 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/rename_private.rs | 14 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/rename_public.rs | 17 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs | 15 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/simple_private.rs | 15 | ||||
-rw-r--r-- | src/test/rustdoc-json/reexport/simple_public.rs | 18 |
13 files changed, 219 insertions, 0 deletions
diff --git a/src/test/rustdoc-json/reexport/auxiliary/pub-struct.rs b/src/test/rustdoc-json/reexport/auxiliary/pub-struct.rs new file mode 100644 index 000000000..4a835673a --- /dev/null +++ b/src/test/rustdoc-json/reexport/auxiliary/pub-struct.rs @@ -0,0 +1 @@ +pub struct Foo; diff --git a/src/test/rustdoc-json/reexport/glob_extern.rs b/src/test/rustdoc-json/reexport/glob_extern.rs new file mode 100644 index 000000000..ba1cfd8a0 --- /dev/null +++ b/src/test/rustdoc-json/reexport/glob_extern.rs @@ -0,0 +1,18 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @is glob_extern.json "$.index[*][?(@.name=='mod1')].kind" \"module\" +// @is glob_extern.json "$.index[*][?(@.name=='mod1')].inner.is_stripped" "true" +mod mod1 { + extern "C" { + // @has - "$.index[*][?(@.name=='public_fn')].id" + pub fn public_fn(); + // @!has - "$.index[*][?(@.name=='private_fn')]" + fn private_fn(); + } +} + +// @is - "$.index[*][?(@.kind=='import')].inner.glob" true +pub use mod1::*; diff --git a/src/test/rustdoc-json/reexport/glob_private.rs b/src/test/rustdoc-json/reexport/glob_private.rs new file mode 100644 index 000000000..e6a44748c --- /dev/null +++ b/src/test/rustdoc-json/reexport/glob_private.rs @@ -0,0 +1,32 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @is glob_private.json "$.index[*][?(@.name=='mod1')].kind" \"module\" +// @is glob_private.json "$.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; + } + + // @has - "$.index[*][?(@.kind=='import' && @.inner.name=='mod2')]" + pub use self::mod2::*; + + // @set m1pub_id = - "$.index[*][?(@.name=='Mod1Public')].id" + pub struct Mod1Public; + // @!has - "$.index[*][?(@.name=='Mod1Private')]" + struct Mod1Private; +} + +// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='mod1')]" +pub use mod1::*; + +// @has - "$.index[*][?(@.name=='mod2')].inner.items[*]" $m2pub_id +// @has - "$.index[*][?(@.name=='mod1')].inner.items[*]" $m1pub_id diff --git a/src/test/rustdoc-json/reexport/in_root_and_mod.rs b/src/test/rustdoc-json/reexport/in_root_and_mod.rs new file mode 100644 index 000000000..7bf10a986 --- /dev/null +++ b/src/test/rustdoc-json/reexport/in_root_and_mod.rs @@ -0,0 +1,17 @@ +#![feature(no_core)] +#![no_core] + +// @is in_root_and_mod.json "$.index[*][?(@.name=='foo')].kind" \"module\" +// @is in_root_and_mod.json "$.index[*][?(@.name=='foo')].inner.is_stripped" "true" +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/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs b/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs new file mode 100644 index 000000000..2daadf762 --- /dev/null +++ b/src/test/rustdoc-json/reexport/in_root_and_mod_pub.rs @@ -0,0 +1,20 @@ +#![feature(no_core)] +#![no_core] + +pub mod foo { + // @set bar_id = in_root_and_mod_pub.json "$.index[*][?(@.name=='Bar')].id" + // @has - "$.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 + // @has - "$.index[*][?(@.name=='baz')].inner.items[*]" $baz_import_id + pub use crate::foo::Bar; +} diff --git a/src/test/rustdoc-json/reexport/macro.rs b/src/test/rustdoc-json/reexport/macro.rs new file mode 100644 index 000000000..b86614ffb --- /dev/null +++ b/src/test/rustdoc-json/reexport/macro.rs @@ -0,0 +1,17 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @count macro.json "$.index[*][?(@.name=='macro')].inner.items[*]" 2 + +// @set repro_id = macro.json "$.index[*][?(@.name=='repro')].id" +// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro_id +#[macro_export] +macro_rules! repro { + () => {}; +} + +// @set repro2_id = macro.json "$.index[*][?(@.inner.name=='repro2')].id" +// @has - "$.index[*][?(@.name=='macro')].inner.items[*]" $repro2_id +pub use crate::repro as repro2; diff --git a/src/test/rustdoc-json/reexport/private_twice_one_inline.rs b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs new file mode 100644 index 000000000..327b0f45f --- /dev/null +++ b/src/test/rustdoc-json/reexport/private_twice_one_inline.rs @@ -0,0 +1,18 @@ +// aux-build:pub-struct.rs + +// Test for the ICE in rust/83057 +// Am 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)] +pub use foo::Foo; + +pub mod bar { + pub use foo::Foo; +} + +// @count private_twice_one_inline.json "$.index[*][?(@.kind=='import')]" 2 diff --git a/src/test/rustdoc-json/reexport/private_two_names.rs b/src/test/rustdoc-json/reexport/private_two_names.rs new file mode 100644 index 000000000..36d6a50d3 --- /dev/null +++ b/src/test/rustdoc-json/reexport/private_two_names.rs @@ -0,0 +1,17 @@ +// Test for the ICE in rust/83720 +// A pub-in-private type re-exported under two different names shouldn't cause an error + +#![no_core] +#![feature(no_core)] + +// @is private_two_names.json "$.index[*][?(@.name=='style')].kind" \"module\" +// @is private_two_names.json "$.index[*][?(@.name=='style')].inner.is_stripped" "true" +mod style { + // @has - "$.index[*](?(@.name=='Color'))" + pub struct Color; +} + +// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='Color')]" +pub use style::Color; +// @has - "$.index[*][?(@.kind=='import' && @.inner.name=='Colour')]" +pub use style::Color as Colour; diff --git a/src/test/rustdoc-json/reexport/rename_private.rs b/src/test/rustdoc-json/reexport/rename_private.rs new file mode 100644 index 000000000..2476399bd --- /dev/null +++ b/src/test/rustdoc-json/reexport/rename_private.rs @@ -0,0 +1,14 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @is rename_private.json "$.index[*][?(@.name=='inner')].kind" \"module\" +// @is rename_private.json "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" +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/src/test/rustdoc-json/reexport/rename_public.rs b/src/test/rustdoc-json/reexport/rename_public.rs new file mode 100644 index 000000000..2dd438d22 --- /dev/null +++ b/src/test/rustdoc-json/reexport/rename_public.rs @@ -0,0 +1,17 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @set inner_id = rename_public.json "$.index[*][?(@.name=='inner')].id" +// @has - "$.index[*][?(@.name=='rename_public')].inner.items[*]" $inner_id +pub mod inner { + // @set public_id = - "$.index[*][?(@.name=='Public')].id" + // @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + pub struct Public; +} +// @set import_id = - "$.index[*][?(@.inner.name=='NewName')].id" +// @!has - "$.index[*][?(@.inner.name=='Public')]" +// @has - "$.index[*][?(@.name=='rename_public')].inner.items[*]" $import_id +// @is - "$.index[*][?(@.inner.name=='NewName')].inner.source" \"inner::Public\" +pub use inner::Public as NewName; diff --git a/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs b/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs new file mode 100644 index 000000000..eedddd6a7 --- /dev/null +++ b/src/test/rustdoc-json/reexport/same_type_reexported_more_than_once.rs @@ -0,0 +1,15 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/97432>. + +#![feature(no_core)] +#![no_std] +#![no_core] + +// @has same_type_reexported_more_than_once.json +// @has - "$.index[*][?(@.name=='Trait')]" +pub use inner::Trait; +// @has - "$.index[*].inner[?(@.name=='Reexport')].id" +pub use inner::Trait as Reexport; + +mod inner { + pub trait Trait {} +} diff --git a/src/test/rustdoc-json/reexport/simple_private.rs b/src/test/rustdoc-json/reexport/simple_private.rs new file mode 100644 index 000000000..5ec13e403 --- /dev/null +++ b/src/test/rustdoc-json/reexport/simple_private.rs @@ -0,0 +1,15 @@ +// edition:2018 +#![no_core] +#![feature(no_core)] + +// @is simple_private.json "$.index[*][?(@.name=='inner')].kind" \"module\" +// @is simple_private.json "$.index[*][?(@.name=='inner')].inner.is_stripped" "true" +mod inner { + // @set pub_id = - "$.index[*][?(@.name=='Public')].id" + pub struct Public; +} + +// @is - "$.index[*][?(@.kind=='import')].inner.name" \"Public\" +pub use inner::Public; + +// @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $pub_id diff --git a/src/test/rustdoc-json/reexport/simple_public.rs b/src/test/rustdoc-json/reexport/simple_public.rs new file mode 100644 index 000000000..2e4de301f --- /dev/null +++ b/src/test/rustdoc-json/reexport/simple_public.rs @@ -0,0 +1,18 @@ +// edition:2018 + +#![no_core] +#![feature(no_core)] + +// @set inner_id = simple_public.json "$.index[*][?(@.name=='inner')].id" +// @has - "$.index[*][?(@.name=='simple_public')].inner.items[*]" $inner_id +pub mod inner { + + // @set public_id = - "$.index[*][?(@.name=='Public')].id" + // @has - "$.index[*][?(@.name=='inner')].inner.items[*]" $public_id + pub struct Public; +} + +// @set import_id = - "$.index[*][?(@.inner.name=='Public')].id" +// @has - "$.index[*][?(@.name=='simple_public')].inner.items[*]" $import_id +// @is - "$.index[*][?(@.inner.name=='Public')].inner.source" \"inner::Public\" +pub use inner::Public; |