Skip to content

Rustdoc-Json: Report discriminant on all kinds of enum variant. #106299

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
aDotInTheVoid opened this issue Dec 30, 2022 · 0 comments · Fixed by #106354
Closed

Rustdoc-Json: Report discriminant on all kinds of enum variant. #106299

aDotInTheVoid opened this issue Dec 30, 2022 · 0 comments · Fixed by #106354
Assignees
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@aDotInTheVoid
Copy link
Member

aDotInTheVoid commented Dec 30, 2022

Rust now supports adding an explicit discriminant to all kinds of enum variant.

Eg:

#[repr(u8)]
enum Foo {
    Bar(i32) = 1,
    Baz { a: i32, b: i32 } = 2,
}

However we currently only report it for unit variants.

pub enum Variant {
/// A variant with no parentheses, and possible discriminant.
///
/// ```rust
/// enum Demo {
/// PlainVariant,
/// PlainWithDiscriminant = 1,
/// }
/// ```
Plain(Option<Discriminant>),
/// A variant with unnamed fields.
///
/// Unlike most of json, `#[doc(hidden)]` fields will be given as `None`
/// instead of being omitted, because order matters.
///
/// ```rust
/// enum Demo {
/// TupleVariant(i32),
/// EmptyTupleVariant(),
/// }
/// ```
Tuple(Vec<Option<Id>>),
/// A variant with named fields.
///
/// ```rust
/// enum Demo {
/// StructVariant { x: i32 },
/// EmptyStructVariant {},
/// }
/// ```
Struct { fields: Vec<Id>, fields_stripped: bool },
}

But it should be for all variants.

@rustbot claim

@aDotInTheVoid aDotInTheVoid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-json Area: Rustdoc JSON backend labels Dec 30, 2022
compiler-errors added a commit to compiler-errors/rust that referenced this issue Jan 2, 2023
…GuillaumeGomez

Rustdoc-Json: Report discriminant on all kinds of enum variant.

Closes rust-lang#106299

Probably easier to review one commit at a time.

r? `@GuillaumeGomez`
@bors bors closed this as completed in cca5d21 Jan 3, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-rustdoc-json Area: Rustdoc JSON backend T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant