aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-03-18 15:25:34 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-03-19 08:44:25 +0000
commit1b0076675d8fec6df6d175fe84ff9d2fcba492af (patch)
tree3e9e5375c187afbe445d157f043f2c7083b3b83f /gcc
parentf0750d7091a7f9014d4327cc13f4625af2da2500 (diff)
downloadgcc-1b0076675d8fec6df6d175fe84ff9d2fcba492af.zip
gcc-1b0076675d8fec6df6d175fe84ff9d2fcba492af.tar.gz
gcc-1b0076675d8fec6df6d175fe84ff9d2fcba492af.tar.bz2
Pop return type context after resolving the block.
If type inference fails on the BlockExpr vs the expected return type, we will accidently leave trailing context on the return type stack.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-item.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.h b/gcc/rust/typecheck/rust-hir-type-check-item.h
index cf04260..441a1e3 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-item.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-item.h
@@ -77,15 +77,12 @@ public:
auto expected_ret_tyty = resolve_fn_type->get_return_type ();
context->push_return_type (expected_ret_tyty);
- auto result
+ auto block_expr_ty
= TypeCheckExpr::Resolve (function.get_definition ().get (), false);
- auto ret_resolved = expected_ret_tyty->unify (result);
- if (ret_resolved == nullptr)
- return;
-
- context->peek_return_type ()->append_reference (ret_resolved->get_ref ());
context->pop_return_type ();
+
+ expected_ret_tyty->unify (block_expr_ty);
}
private: