-
Notifications
You must be signed in to change notification settings - Fork 163
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
removed EnumItemDiscriminant and associated functions #3355
base: master
Are you sure you want to change the base?
Conversation
* ast/rust-ast-collector.cc (TokenCollector::visit):removed fn * ast/rust-ast-collector.h: "removed defn" * ast/rust-ast-full-decls.h (class EnumItemDiscriminant):remove fn * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):removed fn * ast/rust-ast-visitor.h:"removed defn" * ast/rust-ast.cc (EnumItemDiscriminant::as_string):removed fn (EnumItemDiscriminant::accept_vis):removed fn (FormatArgs::set_outer_attrs): removed fn * ast/rust-item.h (class EnumItem): "added Discriminant expr" (class EnumItemDiscriminant): "removed redundant class" * expand/rust-cfg-strip.cc (CfgStrip::visit):removed fn * expand/rust-cfg-strip.h:"removed defn" * expand/rust-derive.h:"removed defn" * expand/rust-expand-visitor.cc (ExpandVisitor::visit):removed fn * expand/rust-expand-visitor.h:"removed defn" * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):removed fn * hir/rust-ast-lower-base.h:removed defn * hir/rust-ast-lower-enumitem.h:removed defn * parse/rust-parse-impl.h (Parser::parse_enum_item):"modified fn" (Parser::parse_pattern): modified fn * resolve/rust-ast-resolve-base.cc (ResolverBase::visit):removed fn * resolve/rust-ast-resolve-base.h:"removed defn" * resolve/rust-ast-resolve-item.cc (ResolveItem::visit):removed fn * resolve/rust-ast-resolve-item.h:"removed defn" * resolve/rust-ast-resolve-stmt.h:"removed defn" * resolve/rust-ast-resolve-toplevel.h:"removed defn" * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): "fn" * resolve/rust-toplevel-name-resolver-2.0.h:"removed defn" * util/rust-attributes.cc (AttributeChecker::visit):removed fn * util/rust-attributes.h:"removed defn" Signed-off-by: Om Swaroop Nayak <[email protected]>
Hi!
Things like:
are note very helpful... Maybe something like:
would be a bit more descriptive. Also, having an actual description of the change in the commit log would be appreciated. Don't forget that when the changes are contributed to GCC, there's no link to this pull request, and it's expected that the commit log has all the information. Thanks! |
Hi @dkm ! |
* ast/rust-ast-collector.cc (TokenCollector::visit):Removed * ast/rust-ast-collector.h: Removed TokenCollector::visit definition * ast/rust-ast-full-decls.h (class EnumItemDiscriminant):Removed * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit):Removed * ast/rust-ast-visitor.h:Removed DefaultASTVisitor::visit definition * ast/rust-ast.cc (EnumItemDiscriminant::as_string):Removed (EnumItemDiscriminant::accept_vis):Removed (FormatArgs::set_outer_attrs): Removed * ast/rust-item.h (class EnumItem): added a discriminant expression attribute with relevant helper functions and a constructor to initialise enum items with discriminant (class EnumItemDiscriminant): Removed * expand/rust-cfg-strip.cc (CfgStrip::visit):Removed * expand/rust-cfg-strip.h:Removed CfgStrip::visit definition * expand/rust-derive.h:Removed CfgStrip::visit definition * expand/rust-expand-visitor.cc (ExpandVisitor::visit):Removed * expand/rust-expand-visitor.h:Removed ExpandVisitor::visit definition * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit):Removed * hir/rust-ast-lower-base.h:Removed ASTLoweringBase::visit definition * hir/rust-ast-lower-enumitem.h:Removed visit function * parse/rust-parse-impl.h (Parser::parse_enum_item): removed the EnumItemDiscriminant constructor and added the EnumItem constructor with expression (Parser::parse_pattern): modified * resolve/rust-ast-resolve-base.cc (ResolverBase::visit):Removed * resolve/rust-ast-resolve-base.h:Removed ResolverBase::visit definition * resolve/rust-ast-resolve-item.cc (ResolveItem::visit):Removed * resolve/rust-ast-resolve-item.h:Removed ResolveItem::visit definition * resolve/rust-ast-resolve-stmt.h:Removed visit function * resolve/rust-ast-resolve-toplevel.h:Removed visit function * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):Removed * resolve/rust-toplevel-name-resolver-2.0.h:Removed TopLevel::visit definition * util/rust-attributes.cc (AttributeChecker::visit):Removed * util/rust-attributes.h:Removed AttributeChecker::visit definition Signed-off-by: Om Swaroop Nayak <[email protected]>
hi @dkm is the new changelog fine |
@saeitoshi-10 the changelog checks are failing, as you said because the lines are too long. You can just put the second half on a second line with a leading tab character, like in this commit de8606f |
std::move (discriminant_expr), | ||
std::move (outer_attrs), | ||
item_name_tok->get_locus ())); | ||
return std::unique_ptr<AST::EnumItem> (new AST::EnumItem ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we need to add a comment saying that this part needs to be reworked to properly handle enum discriminants, and link to issue #3340
something like:
// FIXME: We need to add special handling for parsing discriminant expressions for all possible enum items, not just enum item identifiers (gccrs#3340)
item_name_tok->get_locus ())); | ||
return std::unique_ptr<AST::EnumItem> (new AST::EnumItem ( | ||
std::move (item_name), std::move (vis), std::move (outer_attrs), | ||
item_name_tok->get_locus (), discriminant_expr->clone_expr ())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to not use the discriminant_expr
here as we can't do anything with it yet. So use the regular constructor.
item_name_tok->get_locus (), discriminant_expr->clone_expr ())); | |
item_name_tok->get_locus ())); |
std::unique_ptr<Expr> expression; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to add handling for this just yet because we're not handling it properly and parsing it for all enum items yet. So I would say remove this
EnumItem (Identifier variant_name, Visibility vis, | ||
std::vector<Attribute> outer_attrs, location_t locus, | ||
std::unique_ptr<AST::Expr> Discriminant) | ||
: VisItem (std::move (vis), std::move (outer_attrs)), | ||
variant_name (std::move (variant_name)), locus (locus), | ||
expression (Discriminant->clone_expr ()) | ||
{} | ||
|
||
EnumItem (EnumItem const &other) | ||
: VisItem (other), variant_name (other.variant_name), locus (other.locus), | ||
expression (other.expression->clone_expr ()) | ||
{} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove these constructors
bool has_expr () { return expression != nullptr; } | ||
|
||
Expr &get_expr () | ||
{ | ||
rust_assert (expression != nullptr); | ||
return *expression; | ||
} | ||
|
||
std::unique_ptr<Expr> &get_expr_ptr () | ||
{ | ||
rust_assert (expression != nullptr); | ||
return expression; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need these as well
Thank you for making Rust GCC better!
If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.
Here is a checklist to help you with your PR.
make check-rust
passes locallyclang-format
gcc/testsuite/rust/
Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.
Fixes #3340
*Please write a comment explaining your change. This is the message
that will be part of the merge commit.