Skip to content

Commit 232bdaf

Browse files
committed
rustdoc: show attributes on enum variants
mostly for #[non_exhaustive]
1 parent 3129d37 commit 232bdaf

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/librustdoc/html/render/print_item.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,7 @@ fn render_enum_fields(
17021702
if v.is_stripped() {
17031703
continue;
17041704
}
1705+
write!(w, "{}", render_attributes_in_pre(v, TAB, cx))?;
17051706
w.write_str(TAB)?;
17061707
match v.kind {
17071708
clean::VariantItem(ref var) => match var.kind {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![crate_name = "foo"]
2+
3+
//@ snapshot type-code 'foo/enum.Type.html' '//pre[@class="rust item-decl"]/code'
4+
pub enum Type {
5+
#[non_exhaustive]
6+
// attribute that should not be shown
7+
#[warn(unsafe_code)]
8+
Variant,
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<code>pub enum Type {
2+
#[non_exhaustive]
3+
Variant,
4+
}</code>

0 commit comments

Comments
 (0)