summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-json
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rustdoc-json')
-rw-r--r--tests/rustdoc-json/enums/field_order.rs40
-rw-r--r--tests/rustdoc-json/enums/variant_order.rs38
-rw-r--r--tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs15
-rw-r--r--tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs14
-rw-r--r--tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs21
-rw-r--r--tests/rustdoc-json/structs/field_order.rs38
-rw-r--r--tests/rustdoc-json/traits/private_supertrait.rs15
-rw-r--r--tests/rustdoc-json/type/inherent_associated_type_bound.rs17
-rw-r--r--tests/rustdoc-json/type/inherent_associated_type_projections.rs12
-rw-r--r--tests/rustdoc-json/unions/field_order.rs38
10 files changed, 235 insertions, 13 deletions
diff --git a/tests/rustdoc-json/enums/field_order.rs b/tests/rustdoc-json/enums/field_order.rs
new file mode 100644
index 000000000..e89add9cb
--- /dev/null
+++ b/tests/rustdoc-json/enums/field_order.rs
@@ -0,0 +1,40 @@
+// Check that the order of fields is preserved.
+
+pub enum Whatever {
+ Foo {
+ // Important: random prefixes are used here to ensure that
+ // sorting fields by name would cause this test to fail.
+ ews_0: i32,
+ dik_1: i32,
+ hsk_2: i32,
+ djt_3: i32,
+ jnr_4: i32,
+ dfs_5: i32,
+ bja_6: i32,
+ lyc_7: i32,
+ yqd_8: i32,
+ vll_9: i32,
+ },
+}
+
+// @set 0 = '$.index[*][?(@.name == "ews_0")].id'
+// @set 1 = '$.index[*][?(@.name == "dik_1")].id'
+// @set 2 = '$.index[*][?(@.name == "hsk_2")].id'
+// @set 3 = '$.index[*][?(@.name == "djt_3")].id'
+// @set 4 = '$.index[*][?(@.name == "jnr_4")].id'
+// @set 5 = '$.index[*][?(@.name == "dfs_5")].id'
+// @set 6 = '$.index[*][?(@.name == "bja_6")].id'
+// @set 7 = '$.index[*][?(@.name == "lyc_7")].id'
+// @set 8 = '$.index[*][?(@.name == "yqd_8")].id'
+// @set 9 = '$.index[*][?(@.name == "vll_9")].id'
+
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[0]' $0
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[1]' $1
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[2]' $2
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[3]' $3
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[4]' $4
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[5]' $5
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[6]' $6
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[7]' $7
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[8]' $8
+// @is '$.index[*][?(@.name == "Foo")].inner.variant.kind.struct.fields[9]' $9
diff --git a/tests/rustdoc-json/enums/variant_order.rs b/tests/rustdoc-json/enums/variant_order.rs
new file mode 100644
index 000000000..17ca96213
--- /dev/null
+++ b/tests/rustdoc-json/enums/variant_order.rs
@@ -0,0 +1,38 @@
+// Check that the order of variants is preserved.
+
+pub enum Foo {
+ // Important: random prefixes are used here to ensure that
+ // sorting fields by name would cause this test to fail.
+ Ews0,
+ Dik1,
+ Hsk2,
+ Djt3,
+ Jnr4,
+ Dfs5,
+ Bja6,
+ Lyc7,
+ Yqd8,
+ Vll9,
+}
+
+// @set 0 = '$.index[*][?(@.name == "Ews0")].id'
+// @set 1 = '$.index[*][?(@.name == "Dik1")].id'
+// @set 2 = '$.index[*][?(@.name == "Hsk2")].id'
+// @set 3 = '$.index[*][?(@.name == "Djt3")].id'
+// @set 4 = '$.index[*][?(@.name == "Jnr4")].id'
+// @set 5 = '$.index[*][?(@.name == "Dfs5")].id'
+// @set 6 = '$.index[*][?(@.name == "Bja6")].id'
+// @set 7 = '$.index[*][?(@.name == "Lyc7")].id'
+// @set 8 = '$.index[*][?(@.name == "Yqd8")].id'
+// @set 9 = '$.index[*][?(@.name == "Vll9")].id'
+
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[0]' $0
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[1]' $1
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[2]' $2
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[3]' $3
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[4]' $4
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[5]' $5
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[6]' $6
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[7]' $7
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[8]' $8
+// @is '$.index[*][?(@.name == "Foo")].inner.enum.variants[9]' $9
diff --git a/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs
new file mode 100644
index 000000000..d2ac316d4
--- /dev/null
+++ b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-2.rs
@@ -0,0 +1,15 @@
+#![feature(no_core)]
+#![no_core]
+
+// @count "$.index[*][?(@.inner.impl)]" 1
+// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
+// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
+// @has "$.index[*][?(@.name=='PubTrait')]"
+pub trait PubTrait {}
+
+#[doc(hidden)]
+pub struct HiddenPubStruct;
+pub struct NotHiddenPubStruct;
+
+impl PubTrait for HiddenPubStruct {}
+impl PubTrait for NotHiddenPubStruct {}
diff --git a/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs
new file mode 100644
index 000000000..fcd27ca4b
--- /dev/null
+++ b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id-3.rs
@@ -0,0 +1,14 @@
+// compile-flags: --document-hidden-items
+
+#![feature(no_core)]
+#![no_core]
+
+// @has "$.index[*][?(@.name == 'HiddenPubStruct')]"
+// @has "$.index[*][?(@.inner.impl)]"
+// @has "$.index[*][?(@.name=='PubTrait')]"
+pub trait PubTrait {}
+
+#[doc(hidden)]
+pub struct HiddenPubStruct;
+
+impl PubTrait for HiddenPubStruct {}
diff --git a/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs
new file mode 100644
index 000000000..141c54a57
--- /dev/null
+++ b/tests/rustdoc-json/impls/issue-112852-dangling-trait-impl-id.rs
@@ -0,0 +1,21 @@
+#![feature(no_core)]
+#![no_core]
+
+// @count "$.index[*][?(@.inner.impl)]" 1
+// @!has "$.index[*][?(@.name == 'HiddenPubStruct')]"
+// @has "$.index[*][?(@.name == 'NotHiddenPubStruct')]"
+// @has "$.index[*][?(@.name=='PubTrait')]"
+pub trait PubTrait {}
+
+#[doc(hidden)]
+pub mod hidden {
+ pub struct HiddenPubStruct;
+
+ impl crate::PubTrait for HiddenPubStruct {}
+}
+
+pub mod not_hidden {
+ pub struct NotHiddenPubStruct;
+
+ impl crate::PubTrait for NotHiddenPubStruct {}
+}
diff --git a/tests/rustdoc-json/structs/field_order.rs b/tests/rustdoc-json/structs/field_order.rs
new file mode 100644
index 000000000..a8c18323d
--- /dev/null
+++ b/tests/rustdoc-json/structs/field_order.rs
@@ -0,0 +1,38 @@
+// Check that the order of fields is preserved.
+
+pub struct Foo {
+ // Important: random prefixes are used here to ensure that
+ // sorting fields by name would cause this test to fail.
+ pub ews_0: i32,
+ pub dik_1: i32,
+ pub hsk_2: i32,
+ pub djt_3: i32,
+ pub jnr_4: i32,
+ pub dfs_5: i32,
+ pub bja_6: i32,
+ pub lyc_7: i32,
+ pub yqd_8: i32,
+ pub vll_9: i32,
+}
+
+// @set 0 = '$.index[*][?(@.name == "ews_0")].id'
+// @set 1 = '$.index[*][?(@.name == "dik_1")].id'
+// @set 2 = '$.index[*][?(@.name == "hsk_2")].id'
+// @set 3 = '$.index[*][?(@.name == "djt_3")].id'
+// @set 4 = '$.index[*][?(@.name == "jnr_4")].id'
+// @set 5 = '$.index[*][?(@.name == "dfs_5")].id'
+// @set 6 = '$.index[*][?(@.name == "bja_6")].id'
+// @set 7 = '$.index[*][?(@.name == "lyc_7")].id'
+// @set 8 = '$.index[*][?(@.name == "yqd_8")].id'
+// @set 9 = '$.index[*][?(@.name == "vll_9")].id'
+
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[0]' $0
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[1]' $1
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[2]' $2
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[3]' $3
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[4]' $4
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[5]' $5
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[6]' $6
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[7]' $7
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[8]' $8
+// @is '$.index[*][?(@.name == "Foo")].inner.struct.kind.plain.fields[9]' $9
diff --git a/tests/rustdoc-json/traits/private_supertrait.rs b/tests/rustdoc-json/traits/private_supertrait.rs
new file mode 100644
index 000000000..49238e5e8
--- /dev/null
+++ b/tests/rustdoc-json/traits/private_supertrait.rs
@@ -0,0 +1,15 @@
+// ignore-tidy-linelength
+
+#![feature(no_core)]
+#![no_core]
+
+
+// @!has "$.index[*][?(@.name == 'sealed')]"
+mod sealed {
+ // @set sealed_id = "$.index[*][?(@.name=='Sealed')].id"
+ pub trait Sealed {}
+}
+
+// @count "$.index[*][?(@.name=='Trait')].inner.trait.bounds[*]" 1
+// @is "$.index[*][?(@.name=='Trait')].inner.trait.bounds[0].trait_bound.trait.id" $sealed_id
+pub trait Trait: sealed::Sealed {}
diff --git a/tests/rustdoc-json/type/inherent_associated_type_bound.rs b/tests/rustdoc-json/type/inherent_associated_type_bound.rs
index 2e9b13d0c..8e39f4718 100644
--- a/tests/rustdoc-json/type/inherent_associated_type_bound.rs
+++ b/tests/rustdoc-json/type/inherent_associated_type_bound.rs
@@ -5,14 +5,15 @@
// @set Carrier = '$.index[*][?(@.name=="Carrier")].id'
pub struct Carrier<'a>(&'a ());
-// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.generic_params[*].name' \""'b"\"
-// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier
-// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\"
-// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"'
-// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.trait' null
-// @is '$.index[*][?(@.name=="User")].inner.typedef.type.function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"'
-
-pub type User = for<'b> fn(Carrier<'b>::Focus<i32>);
+// @count "$.index[*][?(@.name=='user')].inner.function.decl.inputs[*]" 1
+// @is "$.index[*][?(@.name=='user')].inner.function.decl.inputs[0][0]" '"_"'
+// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.generic_params[*].name' \""'b"\"
+// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Carrier
+// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].lifetime' \""'b"\"
+// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.name' '"Focus"'
+// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.trait' null
+// @is '$.index[*][?(@.name=="user")].inner.function.decl.inputs[0][1].function_pointer.decl.inputs[0][1].qualified_path.args.angle_bracketed.args[0].type.primitive' '"i32"'
+pub fn user(_: for<'b> fn(Carrier<'b>::Focus<i32>)) {}
impl<'a> Carrier<'a> {
pub type Focus<T> = &'a mut T;
diff --git a/tests/rustdoc-json/type/inherent_associated_type_projections.rs b/tests/rustdoc-json/type/inherent_associated_type_projections.rs
index 942e323ef..d12e5f4a7 100644
--- a/tests/rustdoc-json/type/inherent_associated_type_projections.rs
+++ b/tests/rustdoc-json/type/inherent_associated_type_projections.rs
@@ -5,11 +5,13 @@
// @set Parametrized = '$.index[*][?(@.name=="Parametrized")].id'
pub struct Parametrized<T>(T);
-// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.id' $Parametrized
-// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\"
-// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.name' '"Proj"'
-// @is '$.index[*][?(@.name=="Test")].inner.typedef.type.qualified_path.trait' null
-pub type Test = Parametrized<i32>::Proj;
+// @count "$.index[*][?(@.name=='test')].inner.function.decl.inputs[*]" 1
+// @is "$.index[*][?(@.name=='test')].inner.function.decl.inputs[0][0]" '"_"'
+// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.self_type.resolved_path.id' $Parametrized
+// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.self_type.resolved_path.args.angle_bracketed.args[0].type.primitive' \"i32\"
+// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.name' '"Proj"'
+// @is '$.index[*][?(@.name=="test")].inner.function.decl.inputs[0][1].qualified_path.trait' null
+pub fn test(_: Parametrized<i32>::Proj) {}
/// param_bool
impl Parametrized<bool> {
diff --git a/tests/rustdoc-json/unions/field_order.rs b/tests/rustdoc-json/unions/field_order.rs
new file mode 100644
index 000000000..8a40bda03
--- /dev/null
+++ b/tests/rustdoc-json/unions/field_order.rs
@@ -0,0 +1,38 @@
+// Check that the order of fields is preserved.
+
+pub union Foo {
+ // Important: random prefixes are used here to ensure that
+ // sorting fields by name would cause this test to fail.
+ pub ews_0: i32,
+ pub dik_1: i32,
+ pub hsk_2: i32,
+ pub djt_3: i32,
+ pub jnr_4: i32,
+ pub dfs_5: i32,
+ pub bja_6: i32,
+ pub lyc_7: i32,
+ pub yqd_8: i32,
+ pub vll_9: i32,
+}
+
+// @set 0 = '$.index[*][?(@.name == "ews_0")].id'
+// @set 1 = '$.index[*][?(@.name == "dik_1")].id'
+// @set 2 = '$.index[*][?(@.name == "hsk_2")].id'
+// @set 3 = '$.index[*][?(@.name == "djt_3")].id'
+// @set 4 = '$.index[*][?(@.name == "jnr_4")].id'
+// @set 5 = '$.index[*][?(@.name == "dfs_5")].id'
+// @set 6 = '$.index[*][?(@.name == "bja_6")].id'
+// @set 7 = '$.index[*][?(@.name == "lyc_7")].id'
+// @set 8 = '$.index[*][?(@.name == "yqd_8")].id'
+// @set 9 = '$.index[*][?(@.name == "vll_9")].id'
+
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[0]' $0
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[1]' $1
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[2]' $2
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[3]' $3
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[4]' $4
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[5]' $5
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[6]' $6
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[7]' $7
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[8]' $8
+// @is '$.index[*][?(@.name == "Foo")].inner.union.fields[9]' $9