aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-ast-resolve.cc
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/resolve/rust-ast-resolve.cc
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/resolve/rust-ast-resolve.cc')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index af04aeb..921b77c 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -349,7 +349,16 @@ ResolveExpr::visit (AST::BlockExpr &expr)
resolver->push_new_label_rib (resolver->get_type_scope ().peek ());
for (auto &s : expr.get_statements ())
- ResolveStmt::go (s.get (), s->get_node_id ());
+ {
+ if (s->is_item ())
+ ResolveStmt::go (s.get (), s->get_node_id ());
+ }
+
+ for (auto &s : expr.get_statements ())
+ {
+ if (!s->is_item ())
+ ResolveStmt::go (s.get (), s->get_node_id ());
+ }
if (expr.has_tail_expr ())
ResolveExpr::go (expr.get_tail_expr ().get (), expr.get_node_id ());