mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 00:56:14 +00:00
be581d9f82
[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: ![image](https://github.com/rust-lang/rust/assets/3050060/03e566ec-c670-47b4-8ca2-b982baa7a0f4) 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: ![image](https://github.com/rust-lang/rust/assets/3050060/b53fbbe0-bdb1-4289-8537-f2dd4988e9ac) 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` |
||
---|---|---|
.. | ||
alias-reexport2.rs | ||
alias-reexport.rs | ||
all-item-types.rs | ||
async-trait-dep.rs | ||
auto-traits.rs | ||
cross_crate_generic_typedef.rs | ||
cross-crate-hidden-assoc-trait-items.rs | ||
cross-crate-hidden-impl-parameter.rs | ||
elided-lifetime.rs | ||
empty.rs | ||
enum-primitive.rs | ||
enum-variant.rs | ||
extern-impl-trait.rs | ||
extern-links.rs | ||
external-cross-doc.md | ||
external-cross.rs | ||
external-doc.md | ||
external-macro-src.rs | ||
html_root.rs | ||
incoherent-impl-types.rs | ||
inline-default-methods.rs | ||
issue-13698.rs | ||
issue-15318.rs | ||
issue-17476.rs | ||
issue-19190-3.rs | ||
issue-20646.rs | ||
issue-20727.rs | ||
issue-21092.rs | ||
issue-22025.rs | ||
issue-26606-macro.rs | ||
issue-28927-1.rs | ||
issue-28927-2.rs | ||
issue-29584.rs | ||
issue-30109-1.rs | ||
issue-34274.rs | ||
issue-36031.rs | ||
issue-40936.rs | ||
issue-46727.rs | ||
issue-48414.rs | ||
issue-53689.rs | ||
issue-57180.rs | ||
issue-61592.rs | ||
issue-73061.rs | ||
issue-85454.rs | ||
issue-86620-1.rs | ||
issue-98697-reexport-with-anonymous-lifetime.rs | ||
issue-99221-aux.rs | ||
issue-99734-aux.rs | ||
issue-100204-aux.rs | ||
issue-113982-doc_auto_cfg-reexport-foreign.rs | ||
jump-to-def-res-err-handling-aux.rs | ||
macro_pub_in_module.rs | ||
masked.rs | ||
mod-stackoverflow.rs | ||
no_html_root.rs | ||
normalize-assoc-item.rs | ||
primitive-doc.rs | ||
primitive-reexport.rs | ||
pub-extern-crate.rs | ||
pub-use-extern-macros.rs | ||
real_gimli.rs | ||
realcore.rs | ||
reexp-stripped.rs | ||
reexport-check.rs | ||
reexport-doc-aux.rs | ||
reexports.rs | ||
rustdoc-default-impl.rs | ||
rustdoc-extern-default-method.rs | ||
rustdoc-extern-method.rs | ||
rustdoc-ffi.rs | ||
rustdoc-impl-parts-crosscrate.rs | ||
source_code.rs | ||
source-code-bar.rs | ||
src-links-external.rs | ||
trait-alias-mention.rs | ||
trait-visibility.rs | ||
unit-return.rs | ||
unstable-trait.rs | ||
variant-struct.rs |