Skip to content

Document recovered field in VariantData. #119121

New issue

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

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

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2788,6 +2788,8 @@ pub enum VariantData {
/// Struct variant.
///
/// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
///
/// The `bool` is whether it was recovered by the parser.
Struct(ThinVec<FieldDef>, bool),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Struct(ThinVec<FieldDef>, bool),
Struct { fields: ThinVec<FieldDef>, recovered: bool },

Personally speaking, I'd prefer the variant fields to be named. Not sure how big the fallout of this change would be though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh-aDotInTheVoid@dev-desktop-eu-1:~/rust$ rg "VariantData::Struct" | wc -l
52

Thats doable, if people are OK with the churn. Not sure what exactly the policy is, but I'd be happy to do that if it'd be accepted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, go ahead and do that. Please just make sure it's in a separate commit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also wondering if that field should be Option<ErrorGuaranteed> instead of bool. Can be a separate PR, but maybe leave a FIXME?

// FIXME: investigate making this a `Option<ErrorGuaranteed>`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just make sure it's in a separate commit.

Seperate to what? I think the best thing to do would be do open a new PR, as it wouldn't have any of the changes from this diff.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separate commit as in separate commit in this PR, lol. I don't see any need to split it out from this PR, but up to you.

/// Tuple variant.
///
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2848,7 +2848,9 @@ pub enum VariantData<'hir> {
/// A struct variant.
///
/// E.g., `Bar { .. }` as in `enum Foo { Bar { .. } }`.
Struct(&'hir [FieldDef<'hir>], /* recovered */ bool),
///
/// The `bool` is whether it was recovered by the parser.
Struct(&'hir [FieldDef<'hir>], bool),
/// A tuple variant.
///
/// E.g., `Bar(..)` as in `enum Foo { Bar(..) }`.
Expand Down