aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-11-05 17:42:34 +0000
committerGitHub <noreply@github.com>2021-11-05 17:42:34 +0000
commit57c31311b33e0575adb2c7465f8fa2869e40dbce (patch)
tree21c23aa6eabd9d7fcdfdb2b5c9f2638b12876977 /gcc/rust/hir
parent5074f89f4fd0be3f5fbaf46db604a0b961e7267d (diff)
parent17dc14cb4b0819532376a22b592b26dd6ffc364f (diff)
downloadgcc-57c31311b33e0575adb2c7465f8fa2869e40dbce.zip
gcc-57c31311b33e0575adb2c7465f8fa2869e40dbce.tar.gz
gcc-57c31311b33e0575adb2c7465f8fa2869e40dbce.tar.bz2
Merge #796
796: Handle forward declared items within blocks r=philberty a=philberty This changes the resolution in BlockExpr's to iterate the Items then Stmts but we might want to handle this by desugaring the HIR BlockExpr to have items then stmts to ensure we type resolve the items before the stmts. Fixes #531 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h9
-rw-r--r--gcc/rust/hir/tree/rust-hir-stmt.h6
-rw-r--r--gcc/rust/hir/tree/rust-hir.h4
3 files changed, 10 insertions, 9 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index c472cab..575d1f6 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -2007,15 +2007,6 @@ public:
void accept_vis (HIRVisitor &vis) override;
- void iterate_stmts (std::function<bool (Stmt *)> cb)
- {
- for (auto it = statements.begin (); it != statements.end (); it++)
- {
- if (!cb (it->get ()))
- return;
- }
- }
-
bool is_final_stmt (Stmt *stmt) { return statements.back ().get () == stmt; }
Location get_closing_locus ()
diff --git a/gcc/rust/hir/tree/rust-hir-stmt.h b/gcc/rust/hir/tree/rust-hir-stmt.h
index cc61142..29e98fa 100644
--- a/gcc/rust/hir/tree/rust-hir-stmt.h
+++ b/gcc/rust/hir/tree/rust-hir-stmt.h
@@ -41,6 +41,8 @@ public:
void accept_vis (HIRVisitor &vis) override;
+ bool is_item () const override final { return false; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -119,6 +121,8 @@ public:
HIR::Pattern *get_pattern () { return variables_pattern.get (); }
+ bool is_item () const override final { return false; }
+
protected:
/* Use covariance to implement clone function as returning this object rather
* than base */
@@ -136,6 +140,8 @@ class ExprStmt : public Stmt
public:
Location get_locus () const override final { return locus; }
+ bool is_item () const override final { return false; }
+
protected:
ExprStmt (Analysis::NodeMapping mappings, Location locus)
: Stmt (std::move (mappings)), locus (locus)
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index af18d804..e834553 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -104,6 +104,8 @@ public:
const Analysis::NodeMapping &get_mappings () const { return mappings; }
+ virtual bool is_item () const = 0;
+
protected:
Stmt (Analysis::NodeMapping mappings) : mappings (std::move (mappings)) {}
@@ -140,6 +142,8 @@ public:
AST::AttrVec &get_outer_attrs () { return outer_attrs; }
const AST::AttrVec &get_outer_attrs () const { return outer_attrs; }
+ bool is_item () const override final { return true; }
+
protected:
// Constructor
Item (Analysis::NodeMapping mappings,