aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2024-10-28 18:08:52 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:32:57 +0100
commit6246f658336099f328078f92f277ed461c3bb7e5 (patch)
treeb20779c9fbb63ddd90e95811704c7c268fbe2ee0 /gcc/rust/backend
parent417f4bd3e0bb82e74664417a6c9a7a878e4df462 (diff)
downloadgcc-6246f658336099f328078f92f277ed461c3bb7e5.zip
gcc-6246f658336099f328078f92f277ed461c3bb7e5.tar.gz
gcc-6246f658336099f328078f92f277ed461c3bb7e5.tar.bz2
gccrs: Fixes some tests appearing with a moved variant
A variant being moved lead to a null being created and a segfault later down the line. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Call getter instead of size function. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Only check privacy if the type is present. * hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Use an optional. * hir/tree/rust-hir-generic-param.h: Assert type before getting it. * hir/tree/rust-hir-item.h: Assert pointers before dereference, fix has_type condition. * hir/tree/rust-hir-path.h: Add more assertions. * hir/tree/rust-hir-stmt.cc: Change constructor with optionals. * hir/tree/rust-hir-stmt.h: Use optionals over smart pointers to emphasize these fields might be missing. * hir/tree/rust-hir.cc (LetStmt::as_string): Use getters. * typecheck/rust-hir-type-check-expr.cc: Clone structures to prevent parent's fields from being nulled by the move operation. * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Use optionals. * typecheck/rust-tyty.cc: Likewise. * typecheck/rust-tyty.h: Likewise. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index 107ca2e..673acde 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -1200,7 +1200,7 @@ CompileExpr::visit (HIR::CallExpr &expr)
// this assumes all fields are in order from type resolution and if a
// base struct was specified those fields are filed via accessors
std::vector<tree> arguments;
- for (size_t i = 0; i < expr.get_arguments ().size (); i++)
+ for (size_t i = 0; i < expr.num_params (); i++)
{
auto &argument = expr.get_arguments ().at (i);
auto rvalue = CompileExpr::Compile (*argument, ctx);