diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-04-16 17:37:31 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2025-05-02 14:46:25 +0000 |
commit | ecf19aca7569bca599d8942f2a3a59b7430374b0 (patch) | |
tree | 558c92b42c03e0ae4590f44a40023a51831beefc /gcc | |
parent | 92323dd3bb16f21194891ce463fc865598c6980f (diff) | |
download | gcc-ecf19aca7569bca599d8942f2a3a59b7430374b0.zip gcc-ecf19aca7569bca599d8942f2a3a59b7430374b0.tar.gz gcc-ecf19aca7569bca599d8942f2a3a59b7430374b0.tar.bz2 |
ast: builder: Allow building struct ident patterns
gcc/rust/ChangeLog:
* ast/rust-ast-builder.cc (Builder::struct_pattern_ident_pattern): New.
* ast/rust-ast-builder.h: New declaration.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-ast-builder.cc | 8 | ||||
-rw-r--r-- | gcc/rust/ast/rust-ast-builder.h | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc index 1f49c64..e4c03e5 100644 --- a/gcc/rust/ast/rust-ast-builder.cc +++ b/gcc/rust/ast/rust-ast-builder.cc @@ -442,6 +442,14 @@ Builder::field_access (std::unique_ptr<Expr> &&instance, new FieldAccessExpr (std::move (instance), field, {}, loc)); } +std::unique_ptr<StructPatternField> +Builder::struct_pattern_ident_pattern (std::string field_name, + std::unique_ptr<Pattern> &&pattern) +{ + return std::make_unique<StructPatternFieldIdentPat> ( + field_name, std::move (pattern), std::vector<Attribute> (), loc); +} + std::unique_ptr<Pattern> Builder::wildcard () const { diff --git a/gcc/rust/ast/rust-ast-builder.h b/gcc/rust/ast/rust-ast-builder.h index c0550c4..682af79 100644 --- a/gcc/rust/ast/rust-ast-builder.h +++ b/gcc/rust/ast/rust-ast-builder.h @@ -254,6 +254,10 @@ public: std::unique_ptr<Expr> field_access (std::unique_ptr<Expr> &&instance, std::string field) const; + std::unique_ptr<StructPatternField> + struct_pattern_ident_pattern (std::string field_name, + std::unique_ptr<Pattern> &&pattern); + /* Create a wildcard pattern (`_`) */ std::unique_ptr<Pattern> wildcard () const; /* Create a reference pattern (`&pattern`) */ |