diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-01-08 16:21:59 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-01-09 14:47:04 +0000 |
commit | 6d7a53b684b5765acda82f39f71bc7798bf0ee94 (patch) | |
tree | 96674528f5dc88f78bd39f551624f3ff7105ccb1 | |
parent | 705b8b73aa694a8cc79c4459beca192145f97542 (diff) | |
download | gcc-6d7a53b684b5765acda82f39f71bc7798bf0ee94.zip gcc-6d7a53b684b5765acda82f39f71bc7798bf0ee94.tar.gz gcc-6d7a53b684b5765acda82f39f71bc7798bf0ee94.tar.bz2 |
Fix crash when compiling BlockExpr's
This ensures the compiler respects scoping and shadowing rules of
blocks added within an enclosing scope.
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-block.h | 5 | ||||
-rw-r--r-- | gcc/testsuite/rust.test/compilable/scoping1.rs | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-block.h b/gcc/rust/hir/rust-ast-lower-block.h index 1ef581e..f81a242 100644 --- a/gcc/rust/hir/rust-ast-lower-block.h +++ b/gcc/rust/hir/rust-ast-lower-block.h @@ -129,6 +129,11 @@ public: translated = ASTLoweringIfBlock::translate (&expr, &terminated); } + void visit (AST::BlockExpr &expr) + { + translated = ASTLoweringBlock::translate (&expr, &terminated); + } + private: ASTLoweringExprWithBlock () : ASTLoweringBase (), translated (nullptr), terminated (false) diff --git a/gcc/testsuite/rust.test/compilable/scoping1.rs b/gcc/testsuite/rust.test/compilable/scoping1.rs new file mode 100644 index 0000000..02b5f93 --- /dev/null +++ b/gcc/testsuite/rust.test/compilable/scoping1.rs @@ -0,0 +1,10 @@ +fn main() { + let x = 1; + { + let x = true; + { + x = false; + } + } + let x = x + 1; +} |