summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-05-14 08:21:40 +0200
committerGitHub <noreply@github.com>2023-05-14 08:21:40 +0200
commit70ab314741dc1b0fc943e03a0c0ba6cb68308831 (patch)
tree8682716d86b48df4743d0b3a24af0fef7736aaa1 /tests
parentd7f742532a16ec3a2db3b47e02fdbd6bbbbf9521 (diff)
parentc271c708e2d238bcc19c21fc810c9ed6f8baf324 (diff)
downloadrust-70ab314741dc1b0fc943e03a0c0ba6cb68308831.tar.gz
Rollup merge of #111534 - aDotInTheVoid:ita-rdj, r=fmease,GuillaumeGomez
rustdoc-json: Add tests for `#![feature(inherent_associated_types)]` Follow up to #109410, CC `@fmease` r? `@GuillaumeGomez`
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-json/type/inherent_associated_type.rs29
-rw-r--r--tests/rustdoc-json/type/inherent_associated_type_bound.rs21
-rw-r--r--tests/rustdoc-json/type/inherent_associated_type_projections.rs33
3 files changed, 83 insertions, 0 deletions
diff --git a/tests/rustdoc-json/type/inherent_associated_type.rs b/tests/rustdoc-json/type/inherent_associated_type.rs
new file mode 100644
index 00000000000..ed63def93df
--- /dev/null
+++ b/tests/rustdoc-json/type/inherent_associated_type.rs
@@ -0,0 +1,29 @@
+// ignore-tidy-linelength
+#![feature(inherent_associated_types)]
+#![feature(no_core)]
+#![allow(incomplete_features)]
+#![no_core]
+
+// @set OwnerMetadata = '$.index[*][?(@.name=="OwnerMetadata")].id'
+pub struct OwnerMetadata;
+// @set Owner = '$.index[*][?(@.name=="Owner")].id'
+pub struct Owner;
+
+pub fn create() -> Owner::Metadata {
+ OwnerMetadata
+}
+// @is '$.index[*][?(@.name=="create")].inner.decl.output.kind' '"qualified_path"'
+// @is '$.index[*][?(@.name=="create")].inner.decl.output.inner.name' '"Metadata"'
+// @is '$.index[*][?(@.name=="create")].inner.decl.output.inner.trait' null
+// @is '$.index[*][?(@.name=="create")].inner.decl.output.inner.self_type.kind' '"resolved_path"'
+// @is '$.index[*][?(@.name=="create")].inner.decl.output.inner.self_type.inner.id' $Owner
+
+/// impl
+impl Owner {
+ /// iat
+ pub type Metadata = OwnerMetadata;
+}
+// @set iat = '$.index[*][?(@.docs=="iat")].id'
+// @is '$.index[*][?(@.docs=="impl")].inner.items[*]' $iat
+// @is '$.index[*][?(@.docs=="iat")].kind' '"assoc_type"'
+// @is '$.index[*][?(@.docs=="iat")].inner.default.inner.id' $OwnerMetadata
diff --git a/tests/rustdoc-json/type/inherent_associated_type_bound.rs b/tests/rustdoc-json/type/inherent_associated_type_bound.rs
new file mode 100644
index 00000000000..a089600b692
--- /dev/null
+++ b/tests/rustdoc-json/type/inherent_associated_type_bound.rs
@@ -0,0 +1,21 @@
+// ignore-tidy-linelength
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+// @set Carrier = '$.index[*][?(@.name=="Carrier")].id'
+pub struct Carrier<'a>(&'a ());
+
+// @is '$.index[*][?(@.name=="User")].inner.type.kind' '"function_pointer"'
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.generic_params[*].name' \""'b"\"
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.decl.inputs[0][1].kind' '"qualified_path"'
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.decl.inputs[0][1].inner.self_type.inner.id' $Carrier
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.decl.inputs[0][1].inner.self_type.inner.args.angle_bracketed.args[0].lifetime' \""'b"\"
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.decl.inputs[0][1].inner.name' '"Focus"'
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.decl.inputs[0][1].inner.trait' null
+// @is '$.index[*][?(@.name=="User")].inner.type.inner.decl.inputs[0][1].inner.args.angle_bracketed.args[0].type.inner' '"i32"'
+
+pub type 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
new file mode 100644
index 00000000000..30c68bfe56c
--- /dev/null
+++ b/tests/rustdoc-json/type/inherent_associated_type_projections.rs
@@ -0,0 +1,33 @@
+// ignore-tidy-linelength
+#![feature(inherent_associated_types)]
+#![allow(incomplete_features)]
+
+// @set Parametrized = '$.index[*][?(@.name=="Parametrized")].id'
+pub struct Parametrized<T>(T);
+
+// @is '$.index[*][?(@.name=="Test")].inner.type.kind' '"qualified_path"'
+// @is '$.index[*][?(@.name=="Test")].inner.type.inner.self_type.inner.id' $Parametrized
+// @is '$.index[*][?(@.name=="Test")].inner.type.inner.self_type.inner.args.angle_bracketed.args[0].type' '{"inner": "i32", "kind": "primitive"}'
+// @is '$.index[*][?(@.name=="Test")].inner.type.inner.name' '"Proj"'
+// @is '$.index[*][?(@.name=="Test")].inner.type.inner.trait' null
+pub type Test = Parametrized<i32>::Proj;
+
+/// param_bool
+impl Parametrized<bool> {
+ /// param_bool_proj
+ pub type Proj = ();
+}
+
+/// param_i32
+impl Parametrized<i32> {
+ /// param_i32_proj
+ pub type Proj = String;
+}
+
+// @set param_bool = '$.index[*][?(@.docs=="param_bool")].id'
+// @set param_i32 = '$.index[*][?(@.docs=="param_i32")].id'
+// @set param_bool_proj = '$.index[*][?(@.docs=="param_bool_proj")].id'
+// @set param_i32_proj = '$.index[*][?(@.docs=="param_i32_proj")].id'
+
+// @is '$.index[*][?(@.docs=="param_bool")].inner.items[*]' $param_bool_proj
+// @is '$.index[*][?(@.docs=="param_i32")].inner.items[*]' $param_i32_proj