Skip to content

Commit

Permalink
ast: Add new constructors for PathInExpression
Browse files Browse the repository at this point in the history
This commit adds two new constructors for AST::PathInExpression: One using a provided lang-item, and one with an already built std::unique_ptr<Path>

gcc/rust/ChangeLog:

	* ast/rust-path.h: Add two new constructors.
  • Loading branch information
CohenArthur committed Dec 25, 2024
1 parent d28cae5 commit 797c730
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion gcc/rust/ast/rust-path.h
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,24 @@ class PathInExpression : public Pattern, public ExprWithoutBlock
marked_for_strip (false)
{}

PathInExpression (LangItem::Kind lang_item_kind,
std::vector<Attribute> outer_attrs, location_t locus)
: outer_attrs (std::move (outer_attrs)),
has_opening_scope_resolution (false), locus (locus),
_node_id (Analysis::Mappings::get ().get_next_node_id ()),
path (Rust::make_unique<LangItemPath> (lang_item_kind, locus)),
marked_for_strip (false)
{}

PathInExpression (std::unique_ptr<Path> path,
std::vector<Attribute> outer_attrs, location_t locus,
bool has_opening_scope_resolution = false)
: outer_attrs (std::move (outer_attrs)),
has_opening_scope_resolution (has_opening_scope_resolution),
locus (locus), _node_id (Analysis::Mappings::get ().get_next_node_id ()),
path (std::move (path)), marked_for_strip (false)
{}

PathInExpression (const PathInExpression &other)
: outer_attrs (other.outer_attrs),
has_opening_scope_resolution (other.has_opening_scope_resolution),
Expand All @@ -738,7 +756,7 @@ class PathInExpression : public Pattern, public ExprWithoutBlock
// Creates an error state path in expression.
static PathInExpression create_error ()
{
return PathInExpression ({}, {}, UNDEF_LOCATION);
return PathInExpression (std::vector<PathExprSegment>(), {}, UNDEF_LOCATION);
}

// Returns whether path in expression is in an error state.
Expand Down

0 comments on commit 797c730

Please sign in to comment.