diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/rustdoc-json/primitives | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc-json/primitives')
-rw-r--r-- | tests/rustdoc-json/primitives/local_primitive.rs | 21 | ||||
-rw-r--r-- | tests/rustdoc-json/primitives/primitive_impls.rs | 34 | ||||
-rw-r--r-- | tests/rustdoc-json/primitives/primitive_overloading.rs | 16 | ||||
-rw-r--r-- | tests/rustdoc-json/primitives/primitive_type.rs | 22 | ||||
-rw-r--r-- | tests/rustdoc-json/primitives/use_primitive.rs | 20 |
5 files changed, 113 insertions, 0 deletions
diff --git a/tests/rustdoc-json/primitives/local_primitive.rs b/tests/rustdoc-json/primitives/local_primitive.rs new file mode 100644 index 000000000..f27e6a2ad --- /dev/null +++ b/tests/rustdoc-json/primitives/local_primitive.rs @@ -0,0 +1,21 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/104064>. + +#![feature(no_core)] +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_core] +#![rustc_coherence_is_core] + +//! Link to [i32][prim@i32] [i64][prim@i64] + +#[doc(primitive = "i32")] +mod prim_i32 {} + +// @set local_i32 = "$.index[*][?(@.name=='i32')].id" + +// @has "$.index[*][?(@.name=='local_primitive')]" +// @ismany "$.index[*][?(@.name=='local_primitive')].inner.items[*]" $local_i32 +// @is "$.index[*][?(@.name=='local_primitive')].links['prim@i32']" $local_i32 + +// Let's ensure the `prim_i32` module isn't present in the output JSON: +// @!has "$.index[*][?(@.name=='prim_i32')]" diff --git a/tests/rustdoc-json/primitives/primitive_impls.rs b/tests/rustdoc-json/primitives/primitive_impls.rs new file mode 100644 index 000000000..1fc937406 --- /dev/null +++ b/tests/rustdoc-json/primitives/primitive_impls.rs @@ -0,0 +1,34 @@ +#![feature(no_core)] +#![feature(rustc_attrs)] +#![feature(rustdoc_internals)] +#![no_core] +#![rustc_coherence_is_core] + +// @set impl_i32 = "$.index[*][?(@.docs=='Only core can do this')].id" + +/// Only core can do this +impl i32 { + // @set identity = "$.index[*][?(@.docs=='Do Nothing')].id" + + /// Do Nothing + pub fn identity(self) -> Self { + self + } + + // @is "$.index[*][?(@.docs=='Only core can do this')].inner.items[*]" $identity +} + +// @set Trait = "$.index[*][?(@.name=='Trait')].id" +pub trait Trait {} +// @set impl_trait_for_i32 = "$.index[*][?(@.docs=='impl Trait for i32')].id" +/// impl Trait for i32 +impl Trait for i32 {} + +/// i32 +#[doc(primitive = "i32")] +mod prim_i32 {} + +// @set i32 = "$.index[*][?(@.docs=='i32')].id" +// @is "$.index[*][?(@.docs=='i32')].name" '"i32"' +// @is "$.index[*][?(@.docs=='i32')].inner.name" '"i32"' +// @ismany "$.index[*][?(@.docs=='i32')].inner.impls[*]" $impl_i32 $impl_trait_for_i32 diff --git a/tests/rustdoc-json/primitives/primitive_overloading.rs b/tests/rustdoc-json/primitives/primitive_overloading.rs new file mode 100644 index 000000000..56b35cd14 --- /dev/null +++ b/tests/rustdoc-json/primitives/primitive_overloading.rs @@ -0,0 +1,16 @@ +// compile-flags: --document-private-items + +// Regression test for <https://github.com/rust-lang/rust/issues/98006>. + +#![feature(rustdoc_internals)] +#![feature(no_core)] + +#![no_core] + +// @has "$.index[*][?(@.name=='usize')]" +// @has "$.index[*][?(@.name=='prim')]" + +#[doc(primitive = "usize")] +/// This is the built-in type `usize`. +mod prim { +} diff --git a/tests/rustdoc-json/primitives/primitive_type.rs b/tests/rustdoc-json/primitives/primitive_type.rs new file mode 100644 index 000000000..8024044bc --- /dev/null +++ b/tests/rustdoc-json/primitives/primitive_type.rs @@ -0,0 +1,22 @@ +#![feature(never_type)] + +// @is "$.index[*][?(@.name=='PrimNever')].visibility" \"public\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimNever')].inner.type.inner" \"never\" +pub type PrimNever = !; + +// @is "$.index[*][?(@.name=='PrimStr')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimStr')].inner.type.inner" \"str\" +pub type PrimStr = str; + +// @is "$.index[*][?(@.name=='PrimBool')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimBool')].inner.type.inner" \"bool\" +pub type PrimBool = bool; + +// @is "$.index[*][?(@.name=='PrimChar')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimChar')].inner.type.inner" \"char\" +pub type PrimChar = char; + +// @is "$.index[*][?(@.name=='PrimU8')].inner.type.kind" \"primitive\" +// @is "$.index[*][?(@.name=='PrimU8')].inner.type.inner" \"u8\" +pub type PrimU8 = u8; diff --git a/tests/rustdoc-json/primitives/use_primitive.rs b/tests/rustdoc-json/primitives/use_primitive.rs new file mode 100644 index 000000000..e22927374 --- /dev/null +++ b/tests/rustdoc-json/primitives/use_primitive.rs @@ -0,0 +1,20 @@ +// edition:2018 + +#![feature(rustdoc_internals)] + +#[doc(primitive = "usize")] +mod usize {} + +// @set local_crate_id = "$.index[*][?(@.name=='use_primitive')].crate_id" + +// @has "$.index[*][?(@.name=='ilog10')]" +// @!is "$.index[*][?(@.name=='ilog10')].crate_id" $local_crate_id +// @has "$.index[*][?(@.name=='checked_add')]" +// @!is "$.index[*][?(@.name=='checked_add')]" $local_crate_id +// @!has "$.index[*][?(@.name=='is_ascii_uppercase')]" + +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='my_i32')].inner.id" null +pub use i32 as my_i32; + +// @is "$.index[*][?(@.kind=='import' && @.inner.name=='u32')].inner.id" null +pub use u32; |