From: Arthur Cohen <[email protected]>
gcc/rust/ChangeLog:
* ast/rust-desugar-question-mark.cc (DesugarQuestionMark::go): Add
assertion for the
expr's type.
* ast/rust-desugar-try-block.cc (DesugarTryBlock::go): Likewise.
---
gcc/rust/ast/rust-desugar-question-mark.cc | 3 ++-
gcc/rust/ast/rust-desugar-try-block.cc | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/gcc/rust/ast/rust-desugar-question-mark.cc
b/gcc/rust/ast/rust-desugar-question-mark.cc
index ef2bdb87307..01400d834b0 100644
--- a/gcc/rust/ast/rust-desugar-question-mark.cc
+++ b/gcc/rust/ast/rust-desugar-question-mark.cc
@@ -18,7 +18,6 @@
#include "rust-desugar-question-mark.h"
#include "rust-ast-builder.h"
-#include "rust-ast-visitor.h"
namespace Rust {
namespace AST {
@@ -28,6 +27,8 @@ DesugarQuestionMark::DesugarQuestionMark () {}
void
DesugarQuestionMark::go (std::unique_ptr<Expr> &ptr)
{
+ rust_assert (ptr->get_expr_kind () == Expr::Kind::ErrorPropagation);
+
auto original = static_cast<ErrorPropagationExpr &> (*ptr);
auto desugared = DesugarQuestionMark ().desugar (original);
diff --git a/gcc/rust/ast/rust-desugar-try-block.cc
b/gcc/rust/ast/rust-desugar-try-block.cc
index cd03350e98b..07f06aabec8 100644
--- a/gcc/rust/ast/rust-desugar-try-block.cc
+++ b/gcc/rust/ast/rust-desugar-try-block.cc
@@ -28,6 +28,8 @@ DesugarTryBlock::DesugarTryBlock () {}
void
DesugarTryBlock::go (std::unique_ptr<Expr> &ptr)
{
+ rust_assert (ptr->get_expr_kind () == Expr::Kind::Try);
+
auto original = static_cast<TryExpr &> (*ptr);
auto desugared = DesugarTryBlock ().desugar (original);
--
2.49.0