about summary refs log tree commit diff
path: root/tests/rustdoc
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-06-24 17:47:24 -0500
committerbinarycat <binarycat@envs.net>2025-06-26 12:33:30 -0500
commitb2be01c81567e89142577f9474a810e3a8676cfc (patch)
treecfa0e4e13df30b5a470b19d0274d5c91131d841c /tests/rustdoc
parent3129d37ef7075ee3cbaa3d6cbe1b5794f67192b0 (diff)
downloadrust-b2be01c81567e89142577f9474a810e3a8676cfc.tar.gz
rust-b2be01c81567e89142577f9474a810e3a8676cfc.zip
rustdoc: show attributes on enum variants
mostly for #[non_exhaustive]
Diffstat (limited to 'tests/rustdoc')
-rw-r--r--tests/rustdoc/enum/enum-variant-non_exhaustive.rs17
-rw-r--r--tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html4
-rw-r--r--tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html4
3 files changed, 25 insertions, 0 deletions
diff --git a/tests/rustdoc/enum/enum-variant-non_exhaustive.rs b/tests/rustdoc/enum/enum-variant-non_exhaustive.rs
new file mode 100644
index 00000000000..ea0234a49f6
--- /dev/null
+++ b/tests/rustdoc/enum/enum-variant-non_exhaustive.rs
@@ -0,0 +1,17 @@
+// regression test for https://github.com/rust-lang/rust/issues/142599
+
+#![crate_name = "foo"]
+
+//@ snapshot type-code 'foo/enum.Type.html' '//pre[@class="rust item-decl"]/code'
+pub enum Type {
+    #[non_exhaustive]
+    // attribute that should not be shown
+    #[warn(unsafe_code)]
+    Variant,
+}
+
+// we would love to use the `following-sibling::` axis
+// (along with an `h2[@id="aliased-type"]` query),
+// but unfortunately python doesn't implement that.
+//@ snapshot type-alias-code 'foo/type.TypeAlias.html' '//pre[@class="rust item-decl"][2]/code'
+pub type TypeAlias = Type;
diff --git a/tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html
new file mode 100644
index 00000000000..04eea709079
--- /dev/null
+++ b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html
@@ -0,0 +1,4 @@
+<code>pub enum TypeAlias {
+    #[non_exhaustive]
+    Variant,
+}</code>
\ No newline at end of file
diff --git a/tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html
new file mode 100644
index 00000000000..6c8851ea5df
--- /dev/null
+++ b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html
@@ -0,0 +1,4 @@
+<code>pub enum Type {
+    #[non_exhaustive]
+    Variant,
+}</code>
\ No newline at end of file