diff options
author | Philip Herron <philip.herron@embecosm.com> | 2020-12-30 22:13:41 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-01-06 10:01:17 +0000 |
commit | 36ebe9a0380694c8517536eb37c7134f1323a30b (patch) | |
tree | 06901ff25aa5ea093184e0713bd0363735408959 /gcc/rust/hir/rust-ast-lower.cc | |
parent | 467141184aa274126ff7e2a41d08bb621b7a3fdf (diff) | |
download | gcc-36ebe9a0380694c8517536eb37c7134f1323a30b.zip gcc-36ebe9a0380694c8517536eb37c7134f1323a30b.tar.gz gcc-36ebe9a0380694c8517536eb37c7134f1323a30b.tar.bz2 |
This brings structs back in post HIR changes. It supports structs
where no base struct is referenced and the constructor is in order.
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower.cc')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 93288c3..8dd8800 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -149,5 +149,22 @@ ASTLoweringIfBlock::visit (AST::IfExprConseqIf &expr) expr.get_locus ()); } +// rust-ast-lower-struct-field-expr.h + +void +ASTLowerStructExprField::visit (AST::StructExprFieldIdentifierValue &field) +{ + HIR::Expr *value = ASTLoweringExpr::translate (field.get_value ().get ()); + + auto crate_num = mappings->get_current_crate (); + Analysis::NodeMapping mapping (crate_num, field.get_node_id (), + mappings->get_next_hir_id (crate_num), + UNKNOWN_LOCAL_DEFID); + + translated = new HIR::StructExprFieldIdentifierValue ( + mapping, field.get_field_name (), std::unique_ptr<HIR::Expr> (value), + field.get_locus ()); +} + } // namespace HIR } // namespace Rust |