aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-10-17 17:18:30 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-10-19 19:32:47 +0100
commit5f25f457eca1e04e577aae8e60fe640bb32d36fc (patch)
treea7d78407c59d8614c4b20687da9421a2d3fce5f1 /gcc/rust/ast
parent851b9e14585160f70eb17a9b312c14e3a0d4c3ed (diff)
downloadgcc-5f25f457eca1e04e577aae8e60fe640bb32d36fc.zip
gcc-5f25f457eca1e04e577aae8e60fe640bb32d36fc.tar.gz
gcc-5f25f457eca1e04e577aae8e60fe640bb32d36fc.tar.bz2
Add hir lowering of closure expressions
In the AST we have ClosureExprInner and ClosureExprInnerTyped the first is the closure expression of the form: let closure_inferred = |i| i + 1; The second is of the form: let closure_annotated = |i: i32| -> i32 { i + 1 }; Both of these can be seguared into a single HIR::ClosureExpr with an optional return type and parameter types. Addresses #195
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r--gcc/rust/ast/rust-expr.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index c764f9c..c58fae5 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -2134,8 +2134,6 @@ struct ClosureParam
private:
std::vector<Attribute> outer_attrs;
std::unique_ptr<Pattern> pattern;
-
- // bool has_type_given;
std::unique_ptr<Type> type;
Location locus;
@@ -2202,19 +2200,19 @@ public:
const std::vector<Attribute> &get_outer_attrs () const { return outer_attrs; }
std::vector<Attribute> &get_outer_attrs () { return outer_attrs; }
- // TODO: is this better? Or is a "vis_block" better?
std::unique_ptr<Pattern> &get_pattern ()
{
rust_assert (pattern != nullptr);
return pattern;
}
- // TODO: is this better? Or is a "vis_block" better?
std::unique_ptr<Type> &get_type ()
{
rust_assert (has_type_given ());
return type;
}
+
+ Location get_locus () const { return locus; }
};
// Base closure definition expression AST node - abstract
@@ -2248,6 +2246,8 @@ public:
{
outer_attrs = std::move (new_attrs);
}
+
+ bool get_has_move () const { return has_move; }
};
// Represents a non-type-specified closure expression AST node
@@ -2307,7 +2307,6 @@ public:
return closure_inner == nullptr;
}
- // TODO: is this better? Or is a "vis_block" better?
std::unique_ptr<Expr> &get_definition_expr ()
{
rust_assert (closure_inner != nullptr);