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:

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`
2023-10-09 13:18:47 +00:00
..
2023-10-09 13:18:47 +00:00
2023-09-06 11:16:05 +02:00
2023-04-28 13:16:10 -07:00
2023-01-28 17:18:56 -07:00
2023-06-21 21:53:55 +02:00
2023-10-04 13:04:45 -07:00
2023-08-18 15:19:17 +08:00
2023-03-30 22:56:52 +02:00
2023-03-30 22:56:52 +02:00
2023-01-28 17:18:56 -07:00
2023-07-29 19:47:15 +00:00
2023-07-29 19:47:15 +00:00
2023-10-04 13:04:45 -07:00
2023-09-27 17:22:18 -07:00
2023-10-04 13:04:45 -07:00
2023-07-14 16:38:01 -07:00
2023-07-14 16:38:01 -07:00
2023-07-14 16:38:01 -07:00
2023-07-14 16:38:01 -07:00
2023-07-14 16:38:01 -07:00
2023-04-29 15:36:03 -04:00
2023-07-14 16:38:01 -07:00
2023-03-09 18:08:22 +01:00
2023-01-30 11:06:18 -07:00
2023-06-07 13:29:36 +02:00
2023-01-30 11:06:18 -07:00
2023-09-27 17:22:18 -07:00
2023-01-30 11:06:18 -07:00
2023-04-04 14:03:50 +00:00
2023-02-07 11:23:25 -07:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-03-30 22:56:52 +02:00
2023-02-07 19:00:42 -07:00
2023-07-12 16:50:43 +02:00
2023-01-27 09:04:39 -07:00
2023-04-13 20:35:05 +02:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-09-15 21:32:28 +02:00
2023-06-24 23:39:35 +02:00
2023-06-24 23:39:35 +02:00
2023-02-07 11:23:25 -07:00
2023-01-30 11:06:18 -07:00
2023-10-04 13:04:45 -07:00
2023-10-04 13:04:45 -07:00
2023-06-24 23:14:57 -04:00
2023-03-20 05:21:51 +00:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-08-18 15:19:18 +08:00
2023-07-19 14:34:06 +02:00
2023-01-28 17:18:56 -07:00
2023-02-07 19:00:42 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-10-04 13:04:45 -07:00
2023-10-04 13:04:45 -07:00
2023-10-04 13:04:45 -07:00
2023-09-27 17:22:18 -07:00
2023-01-30 19:04:59 +00:00
2023-06-02 13:51:01 +02:00
2023-02-03 17:58:26 -07:00
2023-02-07 19:00:42 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-07-14 16:38:01 -07:00
2023-10-09 14:33:04 +02:00
2023-10-04 13:04:45 -07:00
2023-07-26 02:11:35 +02:00
2023-06-23 15:12:48 +02:00
2023-06-23 15:12:48 +02:00
2023-01-30 11:06:18 -07:00
2023-03-19 18:02:52 +01:00
2023-07-28 22:23:21 +02:00
2023-02-07 19:00:42 -07:00
2023-02-07 19:00:42 -07:00
2023-01-27 20:33:42 +01:00
2023-04-16 11:38:52 +00:00
2023-09-27 17:22:18 -07:00
2023-08-23 15:54:04 +02:00
2023-10-04 13:04:45 -07:00
2023-09-27 17:22:18 -07:00
2023-05-10 22:49:05 +00:00
2023-10-04 13:04:45 -07:00
2023-07-26 02:11:35 +02:00
2023-01-27 14:41:33 +01:00
2023-01-28 17:18:56 -07:00
2023-09-27 17:22:18 -07:00
2023-01-13 10:09:25 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-08-03 02:18:52 +02:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-02-04 19:10:04 +01:00
2023-06-01 18:35:00 +02:00
2023-02-07 19:00:42 -07:00
2023-09-11 14:17:39 +02:00
2023-02-07 19:00:42 -07:00
2023-07-22 12:27:25 +02:00
2023-01-30 11:06:18 -07:00
2023-02-07 11:23:25 -07:00
2023-01-13 12:38:03 -07:00
2023-01-28 17:18:56 -07:00
2023-02-07 19:00:42 -07:00
2023-04-20 17:49:13 +02:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-02-07 19:00:42 -07:00
2023-01-28 17:18:56 -07:00
2023-04-24 13:12:24 +02:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-01-28 17:18:56 -07:00
2023-07-24 17:07:57 +02:00
2023-07-24 17:07:57 +02:00
2023-07-24 17:07:57 +02:00
2023-07-24 17:07:57 +02:00
2023-07-24 17:07:57 +02:00
2023-01-23 14:31:35 -07:00
2023-01-23 14:31:35 -07:00
2023-02-04 19:10:04 +01:00
2023-09-06 11:16:05 +02:00
2023-04-19 11:32:50 +02:00
2023-02-07 19:00:42 -07:00
2023-01-30 11:06:18 -07:00
2023-01-23 14:31:35 -07:00
2023-01-23 14:31:35 -07:00
2023-01-23 14:31:35 -07:00
2023-08-21 12:53:39 -07:00
2023-07-18 10:41:16 +02:00
2023-04-27 16:25:05 +08:00
2023-01-27 12:11:01 +01:00
2023-02-18 23:24:58 +01:00
2023-02-20 20:19:21 +01:00
2023-02-21 16:26:06 +01:00
2023-03-07 21:20:21 +01:00
2023-03-27 18:58:07 +00:00
2023-03-09 18:08:22 +01:00
2023-03-17 17:04:23 +01:00
2023-08-21 12:53:39 -07:00
2023-03-29 16:17:48 +02:00
2023-04-17 20:27:34 +02:00
2023-04-29 16:53:02 -07:00
2023-06-23 15:12:48 +02:00
2023-05-05 21:33:44 +02:00
2023-06-23 15:12:48 +02:00
2023-06-12 11:35:19 +02:00
2023-07-24 16:32:06 +02:00
2023-02-23 13:53:27 -07:00
2023-02-23 13:53:27 -07:00
2023-07-12 16:50:43 +02:00
2023-01-13 10:09:25 -07:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-01-13 12:38:03 -07:00
2023-04-13 20:35:05 +02:00
2023-10-04 13:04:45 -07:00
2023-01-30 11:06:18 -07:00
2023-09-27 17:22:18 -07:00
2023-10-04 13:04:45 -07:00
2023-09-27 17:22:18 -07:00
2023-01-13 12:38:03 -07:00
2023-01-13 12:38:03 -07:00
2023-01-30 11:06:18 -07:00
2023-01-28 17:18:56 -07:00
2023-05-16 14:35:46 +02:00
2023-03-28 16:50:49 +00:00
2023-03-05 14:41:35 +03:00
2023-04-25 17:20:58 +03:00
2023-01-26 10:51:10 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-09-27 17:22:18 -07:00
2023-03-30 22:56:52 +02:00
2023-03-30 22:56:52 +02:00
2023-03-30 22:56:52 +02:00
2023-02-03 17:58:26 -07:00
2023-03-30 22:56:52 +02:00
2023-09-06 13:26:56 +02:00
2023-07-26 15:29:45 +02:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-06-21 15:21:32 +02:00
2023-06-03 19:57:17 +02:00
2023-02-07 19:00:42 -07:00
2023-01-30 11:06:18 -07:00
2023-06-26 16:38:14 +02:00
2023-05-26 17:31:54 +02:00
2023-05-27 00:25:37 +02:00
2023-02-10 18:37:32 +01:00
2023-05-27 00:25:37 +02:00
2023-02-22 17:49:22 +01:00
2023-02-07 11:23:25 -07:00
2023-01-30 11:06:18 -07:00
2023-09-20 03:02:14 +00:00
2023-01-30 11:06:18 -07:00
2023-10-04 13:04:45 -07:00
2023-02-07 19:00:42 -07:00
2023-02-07 19:00:42 -07:00
2023-09-01 17:22:48 -04:00
2023-08-21 12:53:39 -07:00
2023-02-03 17:58:26 -07:00
2023-01-30 11:06:18 -07:00
2023-07-14 16:54:14 -07:00
2023-10-04 13:04:45 -07:00
2023-07-14 16:38:01 -07:00
2023-10-04 13:04:45 -07:00
2023-10-04 13:04:45 -07:00
2023-07-14 16:54:14 -07:00
2023-01-13 12:38:03 -07:00
2023-10-04 13:04:45 -07:00
2023-01-30 11:06:18 -07:00
2023-03-30 22:56:52 +02:00
2023-01-30 11:06:18 -07:00
2023-05-25 13:27:29 +00:00
2023-08-21 12:53:39 -07:00
2023-01-30 11:06:18 -07:00
2023-01-13 12:38:03 -07:00
2023-01-13 12:38:03 -07:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-01-30 11:06:18 -07:00
2023-03-04 12:07:29 +00:00
2023-08-28 14:03:33 +02:00
2023-08-28 14:03:33 +02:00
2023-01-28 17:18:56 -07:00
2023-06-21 17:42:53 +02:00
2023-01-30 11:06:18 -07:00
2023-04-29 16:19:57 -04:00
2023-02-03 17:58:26 -07:00
2023-01-30 11:06:18 -07:00
2023-09-06 11:16:05 +02:00
2023-06-22 17:39:23 +02:00
2023-06-22 17:39:23 +02:00
2023-06-22 17:39:23 +02:00
2023-09-06 11:16:05 +02:00
2023-06-22 17:39:23 +02:00
2023-09-06 11:16:05 +02:00
2023-02-07 11:23:25 -07:00
2023-02-03 08:15:44 -07:00
2023-02-07 11:23:25 -07:00
2023-01-30 11:06:18 -07:00
2023-02-03 08:15:44 -07:00
2023-02-07 11:23:25 -07:00
2023-02-04 19:10:04 +01:00
2023-02-07 11:23:25 -07:00
2023-02-03 08:15:44 -07:00
2023-02-07 11:23:25 -07:00
2023-01-30 11:06:18 -07:00