diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-07-22 16:29:09 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-08-05 16:36:59 +0200 |
commit | eba7cd78ddf1a8ad7208b09029aff8a88a8d0b89 (patch) | |
tree | d9b96ecd28cad965d41e034b844da23158cd1e86 /gcc/rust | |
parent | 40754a08e5bf529cb57223105b16e608f3d9f030 (diff) | |
download | gcc-eba7cd78ddf1a8ad7208b09029aff8a88a8d0b89.zip gcc-eba7cd78ddf1a8ad7208b09029aff8a88a8d0b89.tar.gz gcc-eba7cd78ddf1a8ad7208b09029aff8a88a8d0b89.tar.bz2 |
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.
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/ast/rust-desugar-question-mark.cc | 3 | ||||
-rw-r--r-- | gcc/rust/ast/rust-desugar-try-block.cc | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/gcc/rust/ast/rust-desugar-question-mark.cc b/gcc/rust/ast/rust-desugar-question-mark.cc index ef2bdb87..01400d8 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 cd03350..07f06aa 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); |