From 1b0076675d8fec6df6d175fe84ff9d2fcba492af Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Thu, 18 Mar 2021 15:25:34 +0000 Subject: 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. --- gcc/rust/typecheck/rust-hir-type-check-item.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'gcc') 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: -- cgit v1.1