[rustdoc] Show enum discrimant if it is a C-like variant Fixes https://github.com/rust-lang/rust/issues/101337. We currently display values for associated constant items in traits:  And we also display constant values like [here](file:///home/imperio/rust/rust/build/x86_64-unknown-linux-gnu/doc/std/f32/consts/constant.E.html). I think that for coherency, we should display values of C-like enum variants. With this change, it looks like this:  As for the display of the constant value itself, I used what we already have to keep coherency. We display the C-like variants value in the following scenario: 1. It is a C-like variant with a value set => all the time 2. It is a C-like variant without a value set: All other variants are C-like variants and at least one them has its value set. Here is the result in code: ```rust // Ax and Bx value will be displayed. enum A { Ax = 12, Bx, } // Ax and Bx value will not be displayed enum B { Ax, Bx, } // Bx value will not be displayed enum C { Ax(u32), Bx, } // Bx value will not be displayed, Cx value will be displayed. #[repr(u32)] enum D { Ax(u32), Bx, Cx = 12, } ``` r? `@notriddle` |
||
|---|---|---|
| .. | ||
| clean | ||
| doctest | ||
| formats | ||
| html | ||
| json | ||
| passes | ||
| theme | ||
| askama.toml | ||
| Cargo.toml | ||
| config.rs | ||
| core.rs | ||
| docfs.rs | ||
| doctest.rs | ||
| error.rs | ||
| externalfiles.rs | ||
| fold.rs | ||
| lib.rs | ||
| lint.rs | ||
| markdown.rs | ||
| README.md | ||
| scrape_examples.rs | ||
| theme.rs | ||
| visit.rs | ||
| visit_ast.rs | ||
| visit_lib.rs | ||
For more information about how librustdoc works, see the rustc dev guide.