From 2c35abe37c1e8fb51fa15892f59aaa248a768960 Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 15 Aug 2023 14:13:17 +0200 Subject: rustdoc: show inner enum and struct in type definition for concrete type --- tests/rustdoc/typedef-inner-variants.rs | 80 +++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 tests/rustdoc/typedef-inner-variants.rs (limited to 'tests/rustdoc') diff --git a/tests/rustdoc/typedef-inner-variants.rs b/tests/rustdoc/typedef-inner-variants.rs new file mode 100644 index 00000000000..e0c5b7dd98f --- /dev/null +++ b/tests/rustdoc/typedef-inner-variants.rs @@ -0,0 +1,80 @@ +#![crate_name = "inner_variants"] + +pub struct Adt; +pub struct Ty; + +// @has 'inner_variants/type.AliasTy.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 0 +pub type AliasTy = Ty; + +// @has 'inner_variants/enum.IrTyKind.html' +pub enum IrTyKind { + /// Doc comment for AdtKind + AdtKind(A), + /// and another one for TyKind + TyKind(A, B), + // no comment + StructKind { a: A, }, +} + +// @has 'inner_variants/type.NearlyTyKind.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 0 +pub type NearlyTyKind = IrTyKind; + +// @has 'inner_variants/type.TyKind.html' +// @count - '//*[@id="variants"]' 1 +// @count - '//*[@id="fields"]' 0 +// @count - '//*[@class="variant"]' 3 +// @matches - '//details[@class="toggle"]//pre[@class="rust item-decl"]//code' "enum TyKind" +pub type TyKind = IrTyKind; + +// @has 'inner_variants/union.OneOr.html' +pub union OneOr { + pub one: i64, + pub or: A, +} + +// @has 'inner_variants/type.OneOrF64.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//*[@class="structfield small-section-header"]' 2 +// @matches - '//details[@class="toggle"]//pre[@class="rust item-decl"]//code' "union OneOrF64" +pub type OneOrF64 = OneOr; + +// @has 'inner_variants/struct.One.html' +pub struct One { + pub val: T, + __hidden: T, +} + +// @has 'inner_variants/type.OneU64.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 1 +// @count - '//*[@class="structfield small-section-header"]' 1 +// @matches - '//details[@class="toggle"]//pre[@class="rust item-decl"]//code' "struct OneU64" +pub type OneU64 = One; + +// @has 'inner_variants/struct.OnceA.html' +pub struct OnceA<'a, A> { + a: &'a A, // private +} + +// @has 'inner_variants/type.Once.html' +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 0 +// @matches - '//details[@class="toggle"]//pre[@class="rust item-decl"]//code' "struct Once<'a>" +pub type Once<'a> = OnceA<'a, i64>; + +// @has 'inner_variants/struct.HighlyGenericStruct.html' +pub struct HighlyGenericStruct { + pub z: (A, B, C, D) +} + +// VERIFY that we NOT show the Aliased Type +// @has 'inner_variants/type.HighlyGenericAABB.html' +// @count - '//details[@class="toggle"]' 0 +// @count - '//*[@id="variants"]' 0 +// @count - '//*[@id="fields"]' 0 +pub type HighlyGenericAABB = HighlyGenericStruct; -- cgit 1.4.1-3-g733a5