diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-05 17:42:34 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-05 17:42:34 +0000 |
commit | 57c31311b33e0575adb2c7465f8fa2869e40dbce (patch) | |
tree | 21c23aa6eabd9d7fcdfdb2b5c9f2638b12876977 /gcc/rust/ast | |
parent | 5074f89f4fd0be3f5fbaf46db604a0b961e7267d (diff) | |
parent | 17dc14cb4b0819532376a22b592b26dd6ffc364f (diff) | |
download | gcc-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/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 4 | ||||
-rw-r--r-- | gcc/rust/ast/rust-stmt.h | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 95e4738..72f2609 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -822,6 +822,8 @@ public: virtual bool is_marked_for_strip () const = 0; NodeId get_node_id () const { return node_id; } + virtual bool is_item () const = 0; + protected: Stmt () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {} @@ -847,6 +849,8 @@ public: add_crate_name (std::vector<std::string> &names ATTRIBUTE_UNUSED) const {} + bool is_item () const override final { return true; } + protected: // Clone function implementation as pure virtual method virtual Item *clone_item_impl () const = 0; diff --git a/gcc/rust/ast/rust-stmt.h b/gcc/rust/ast/rust-stmt.h index b83ca11..a1b4e57 100644 --- a/gcc/rust/ast/rust-stmt.h +++ b/gcc/rust/ast/rust-stmt.h @@ -46,6 +46,8 @@ public: void mark_for_strip () override { marked_for_strip = true; } bool is_marked_for_strip () const override { return marked_for_strip; } + bool is_item () const override final { return false; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -169,6 +171,8 @@ public: return type; } + bool is_item () const override final { return false; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ @@ -186,6 +190,8 @@ class ExprStmt : public Stmt public: Location get_locus () const override final { return locus; } + bool is_item () const override final { return false; } + protected: ExprStmt (Location locus) : locus (locus) {} }; |