]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fixes some tests appearing with a moved variant
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Mon, 28 Oct 2024 17:08:52 +0000 (18:08 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:32:57 +0000 (12:32 +0100)
commit6246f658336099f328078f92f277ed461c3bb7e5
treeb20779c9fbb63ddd90e95811704c7c268fbe2ee0
parent417f4bd3e0bb82e74664417a6c9a7a878e4df462
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>
13 files changed:
gcc/rust/backend/rust-compile-expr.cc
gcc/rust/checks/errors/privacy/rust-privacy-reporter.cc
gcc/rust/hir/rust-ast-lower-stmt.cc
gcc/rust/hir/tree/rust-hir-generic-param.h
gcc/rust/hir/tree/rust-hir-item.h
gcc/rust/hir/tree/rust-hir-path.h
gcc/rust/hir/tree/rust-hir-stmt.cc
gcc/rust/hir/tree/rust-hir-stmt.h
gcc/rust/hir/tree/rust-hir.cc
gcc/rust/typecheck/rust-hir-type-check-expr.cc
gcc/rust/typecheck/rust-hir-type-check-item.cc
gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h