Skip to content

Commit 74f3333

Browse files
committed
ast: Add new constructors for PathInExpression
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.
1 parent b33f634 commit 74f3333

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

gcc/rust/ast/rust-path.h

+20-1
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,24 @@ class PathInExpression : public Pattern, public ExprWithoutBlock
715715
marked_for_strip (false)
716716
{}
717717

718+
PathInExpression (LangItem::Kind lang_item_kind,
719+
std::vector<Attribute> outer_attrs, location_t locus)
720+
: outer_attrs (std::move (outer_attrs)),
721+
has_opening_scope_resolution (false), locus (locus),
722+
_node_id (Analysis::Mappings::get ().get_next_node_id ()),
723+
path (Rust::make_unique<LangItemPath> (lang_item_kind, locus)),
724+
marked_for_strip (false)
725+
{}
726+
727+
PathInExpression (std::unique_ptr<Path> path,
728+
std::vector<Attribute> outer_attrs, location_t locus,
729+
bool has_opening_scope_resolution = false)
730+
: outer_attrs (std::move (outer_attrs)),
731+
has_opening_scope_resolution (has_opening_scope_resolution),
732+
locus (locus), _node_id (Analysis::Mappings::get ().get_next_node_id ()),
733+
path (std::move (path)), marked_for_strip (false)
734+
{}
735+
718736
PathInExpression (const PathInExpression &other)
719737
: outer_attrs (other.outer_attrs),
720738
has_opening_scope_resolution (other.has_opening_scope_resolution),
@@ -738,7 +756,8 @@ class PathInExpression : public Pattern, public ExprWithoutBlock
738756
// Creates an error state path in expression.
739757
static PathInExpression create_error ()
740758
{
741-
return PathInExpression ({}, {}, UNDEF_LOCATION);
759+
return PathInExpression (std::vector<PathExprSegment> (), {},
760+
UNDEF_LOCATION);
742761
}
743762

744763
// Returns whether path in expression is in an error state.

0 commit comments

Comments
 (0)