aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-06-25 13:51:50 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-06-25 13:51:50 +0100
commitf089723609077cd38821c15ad042a45936f949e6 (patch)
treed8f8f094efbc8806111f4ee9b450792853852a48 /gcc/rust/backend
parentcb0db310b3dceff7a3ea6e05c002a3ab1239ac4a (diff)
downloadgcc-f089723609077cd38821c15ad042a45936f949e6.zip
gcc-f089723609077cd38821c15ad042a45936f949e6.tar.gz
gcc-f089723609077cd38821c15ad042a45936f949e6.tar.bz2
Add support for empty struct initilizer
Rust supports unit struct initilization such as S{} this takes this tree and resolves it fully. This should really be all desugared via HIR but that is in progress in another PR.
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-expr.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h
index e92c7cd..fc8ad81 100644
--- a/gcc/rust/backend/rust-compile-expr.h
+++ b/gcc/rust/backend/rust-compile-expr.h
@@ -527,6 +527,20 @@ public:
}
}
+ void visit (HIR::StructExprStruct &struct_expr) override
+ {
+ TyTy::BaseType *tyty = nullptr;
+ if (!ctx->get_tyctx ()->lookup_type (
+ struct_expr.get_mappings ().get_hirid (), &tyty))
+ {
+ rust_error_at (struct_expr.get_locus (), "unknown type");
+ return;
+ }
+
+ rust_assert (tyty->is_unit ());
+ translated = ctx->get_backend ()->unit_expression ();
+ }
+
void visit (HIR::StructExprStructFields &struct_expr) override
{
TyTy::BaseType *tyty = nullptr;