diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-ast-builder.cc | 12 | ||||
-rw-r--r-- | gcc/rust/ast/rust-ast-builder.h | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc index 728d5c0..eccc474 100644 --- a/gcc/rust/ast/rust-ast-builder.cc +++ b/gcc/rust/ast/rust-ast-builder.cc @@ -24,6 +24,7 @@ #include "rust-path.h" #include "rust-item.h" #include "rust-path.h" +#include "rust-system.h" #include "rust-token.h" namespace Rust { @@ -262,9 +263,16 @@ Builder::struct_expr ( std::string struct_name, std::vector<std::unique_ptr<StructExprField>> &&fields) const { + return struct_expr (path_in_expression ({struct_name}), std::move (fields)); +} + +std::unique_ptr<Expr> +Builder::struct_expr ( + PathInExpression struct_name, + std::vector<std::unique_ptr<StructExprField>> &&fields) const +{ return std::unique_ptr<Expr> ( - new StructExprStructFields (path_in_expression ({struct_name}), - std::move (fields), loc)); + new StructExprStructFields (struct_name, std::move (fields), loc)); } std::unique_ptr<StructExprField> diff --git a/gcc/rust/ast/rust-ast-builder.h b/gcc/rust/ast/rust-ast-builder.h index 86279b0..7e224d3 100644 --- a/gcc/rust/ast/rust-ast-builder.h +++ b/gcc/rust/ast/rust-ast-builder.h @@ -160,10 +160,15 @@ public: /** * Create an expression for struct instantiation with fields (`S { a, b: c }`) + * Tuple expressions are call expressions and can thus be constructed with + * `call` */ std::unique_ptr<Expr> struct_expr (std::string struct_name, std::vector<std::unique_ptr<StructExprField>> &&fields) const; + std::unique_ptr<Expr> + struct_expr (PathInExpression struct_name, + std::vector<std::unique_ptr<StructExprField>> &&fields) const; /* Create a field expression for struct instantiation (`field_name: value`) */ std::unique_ptr<StructExprField> |