about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-05-26 03:38:16 +0200
committerGitHub <noreply@github.com>2025-05-26 03:38:16 +0200
commit6257d2fb1c8f673b1abb20d155bac80a2a80937c (patch)
tree0c53455b7537be2dc07e2808ed1259c01107e92a /tests
parent761e5464dde378b103ab63bb7788d0978c396bc0 (diff)
parentec97b0f0b57376550efa4d144b62955970f22f02 (diff)
downloadrust-6257d2fb1c8f673b1abb20d155bac80a2a80937c.tar.gz
rust-6257d2fb1c8f673b1abb20d155bac80a2a80937c.zip
Rollup merge of #140863 - GuillaumeGomez:cleanup-tyalias-render, r=lolbinarycat
[rustdoc] Unify type aliases rendering with other ADT

Fixes #140739.

Better reviewed one commit at a time.

Just one thing I'm wondering: should we also render non-`repr` attributes? If so, I wonder if we shouldn't simply change `clean::TypeAlias` to contain the other ADT directly (`Struct`, `Enum` and `Union`) and remove the `TypeAlias::generics` field.

Can be done in a follow-up too.

cc ``@camelid``
r? ``@notriddle``
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc/type-alias/repr.rs42
-rw-r--r--tests/rustdoc/type-layout.rs2
2 files changed, 43 insertions, 1 deletions
diff --git a/tests/rustdoc/type-alias/repr.rs b/tests/rustdoc/type-alias/repr.rs
new file mode 100644
index 00000000000..cf907980360
--- /dev/null
+++ b/tests/rustdoc/type-alias/repr.rs
@@ -0,0 +1,42 @@
+// This test ensures that the `repr` attribute is displayed in type aliases.
+//
+// Regression test for <https://github.com/rust-lang/rust/issues/140739>.
+
+#![crate_name = "foo"]
+
+/// bla
+#[repr(C)]
+pub struct Foo1;
+
+//@ has 'foo/type.Bar1.html'
+//@ has - '//*[@class="rust item-decl"]/code' '#[repr(C)]pub struct Bar1;'
+// Ensures that we see the doc comment of the type alias and not of the aliased type.
+//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar'
+/// bar
+pub type Bar1 = Foo1;
+
+/// bla
+#[repr(C)]
+pub union Foo2 {
+    pub a: u8,
+}
+
+//@ has 'foo/type.Bar2.html'
+//@ matches - '//*[@class="rust item-decl"]' '#\[repr\(C\)\]\npub union Bar2 \{*'
+// Ensures that we see the doc comment of the type alias and not of the aliased type.
+//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar'
+/// bar
+pub type Bar2 = Foo2;
+
+/// bla
+#[repr(C)]
+pub enum Foo3 {
+    A,
+}
+
+//@ has 'foo/type.Bar3.html'
+//@ matches - '//*[@class="rust item-decl"]' '#\[repr\(C\)\]pub enum Bar3 \{*'
+// Ensures that we see the doc comment of the type alias and not of the aliased type.
+//@ has - '//*[@class="toggle top-doc"]/*[@class="docblock"]' 'bar'
+/// bar
+pub type Bar3 = Foo3;
diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs
index 6de435dbcc1..482b8b597dd 100644
--- a/tests/rustdoc/type-layout.rs
+++ b/tests/rustdoc/type-layout.rs
@@ -61,7 +61,7 @@ pub type TypeAlias = X;
 pub type GenericTypeAlias = (Generic<(u32, ())>, Generic<u32>);
 
 // Regression test for the rustdoc equivalent of #85103.
-//@ hasraw type_layout/type.Edges.html 'Encountered an error during type layout; the type failed to be normalized.'
+//@ hasraw type_layout/type.Edges.html 'Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.'
 pub type Edges<'a, E> = std::borrow::Cow<'a, [E]>;
 
 //@ !hasraw type_layout/trait.MyTrait.html 'Size: '