From c271c708e2d238bcc19c21fc810c9ed6f8baf324 Mon Sep 17 00:00:00 2001 From: Alona Enraght-Moony Date: Sat, 13 May 2023 13:07:23 +0000 Subject: [PATCH] rustdoc-json: Add tests for `#![feature(inherent_associated_types)]` --- .../type/inherent_associated_type.rs | 29 ++++++++++++++++ .../type/inherent_associated_type_bound.rs | 21 ++++++++++++ .../inherent_associated_type_projections.rs | 33 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 tests/rustdoc-json/type/inherent_associated_type.rs create mode 100644 tests/rustdoc-json/type/inherent_associated_type_bound.rs create mode 100644 tests/rustdoc-json/type/inherent_associated_type_projections.rs 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 0000000000000..ed63def93df0c --- /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 0000000000000..a089600b692d6 --- /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); + +impl<'a> Carrier<'a> { + pub type Focus = &'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 0000000000000..30c68bfe56c91 --- /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); + +// @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::Proj; + +/// param_bool +impl Parametrized { + /// param_bool_proj + pub type Proj = (); +} + +/// param_i32 +impl Parametrized { + /// 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