rust/src/librustdoc
bors be581d9f82 Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmease
[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`
2023-10-09 13:18:47 +00:00
..
clean Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmease 2023-10-09 13:18:47 +00:00
doctest pass unused_extern_crates in librustdoc::doctest::make_test 2023-04-25 17:20:58 +03:00
formats Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
html Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmease 2023-10-09 13:18:47 +00:00
json Auto merge of #116142 - GuillaumeGomez:enum-variant-display, r=fmease 2023-10-09 13:18:47 +00:00
passes Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
theme rustdoc: merge theme css into rustdoc.css 2023-09-15 07:40:17 -07:00
askama.toml Remove unneeded minus sign in jinja tags 2023-03-06 11:38:15 +01:00
Cargo.toml rustdoc: DocFS: Replace rayon with threadpool and enable it for all targets 2023-03-14 20:28:00 +01:00
config.rs rustdoc: merge theme css into rustdoc.css 2023-09-15 07:40:17 -07:00
core.rs Merge ExternProviders into the general Providers struct 2023-09-22 20:15:34 +00:00
docfs.rs Use more named format args 2023-08-16 16:35:23 +02:00
doctest.rs fix clippy::{redundant_guards, useless_format} 2023-09-27 23:49:15 +02:00
error.rs Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
externalfiles.rs Don't emit an error if the custom_code_classes_in_docs feature is disabled when its syntax is used. 2023-09-17 15:11:44 +02:00
fold.rs rustdoc: bind typedef inner type items to the folding system 2023-08-26 00:15:02 +02:00
lib.rs Delete obsolete --disable-per-crate-search rustdoc flag 2023-09-20 22:09:48 -07:00
lint.rs Add warn level lint redundant_explicit_links 2023-08-18 15:19:08 +08:00
markdown.rs Update src/librustdoc/markdown.rs 2023-09-17 18:43:54 +00:00
README.md rust-lang.github.io/rustc-dev-guide -> rustc-dev-guide.rust-lang.org 2020-03-10 17:08:18 -03:00
scrape_examples.rs Use relative positions inside a SourceFile. 2023-09-03 12:56:10 +00:00
theme.rs rustdoc: merge theme css into rustdoc.css 2023-09-15 07:40:17 -07:00
visit.rs rustdoc: Rename clean items from typedef to type alias 2023-08-21 13:56:22 -07:00
visit_ast.rs Improve code readability by moving fmt args directly into the string 2023-08-16 16:35:23 +02:00
visit_lib.rs Correctly handle --document-hidden-items 2023-07-14 17:25:09 +02:00

For more information about how librustdoc works, see the rustc dev guide.