From: Arthur Cohen Date: Tue, 22 Jul 2025 14:29:09 +0000 (+0200) Subject: gccrs: desugar: Add assertions for try-blocks and question-mark X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=eba7cd78ddf1a8ad7208b09029aff8a88a8d0b89;p=thirdparty%2Fgcc.git gccrs: desugar: Add assertions for try-blocks and question-mark 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. --- 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 &ptr) { + rust_assert (ptr->get_expr_kind () == Expr::Kind::ErrorPropagation); + auto original = static_cast (*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 &ptr) { + rust_assert (ptr->get_expr_kind () == Expr::Kind::Try); + auto original = static_cast (*ptr); auto desugared = DesugarTryBlock ().desugar (original);