]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: unify how we handle DST's
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 8 May 2023 13:10:57 +0000 (14:10 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:37:15 +0000 (18:37 +0100)
commitc9600aa54d7412f5bbff97be2046c8054e201c3c
tree3291eb32d16f0c1e15ee99ae4f10910fcf4df5d9
parente857a3b67905628c97360df77f8f2c8456e4e7b9
gccrs: unify how we handle DST's

DST's are not truely reference types they are "unsized types" so
the exact size of them is not known at compile time. We actually
achieve this by pretending they are a reference but really its
struct we pass around.

Fixes #2180

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::visit): refactr
(CompileExpr::get_fn_addr_from_dyn): likewise
(CompileExpr::get_receiver_from_dyn): likewise
(CompileExpr::type_cast_expression): likewise
* backend/rust-compile-type.cc (TyTyResolveCompile::visit): likewise
(TyTyResolveCompile::create_dyn_obj_record): likewise
(TyTyResolveCompile::create_slice_type_record): likewise
(TyTyResolveCompile::create_str_type_record): likewise
* backend/rust-compile-type.h: likewise
* backend/rust-compile.cc (HIRCompileBase::coercion_site1): likewise
(HIRCompileBase::coerce_to_dyn_object): refactor
* backend/rust-tree.h (SLICE_FLAG): removed
(SLICE_TYPE_P): removed
(RS_DST_FLAG): new flag
(RS_DST_FLAG_P): new predicate
* typecheck/rust-tyty.cc (ReferenceType::is_dyn_object): new helper
(ReferenceType::is_dyn_obj_type): likewise
(PointerType::is_dyn_object): likewise
(PointerType::is_dyn_obj_type): likewise
* typecheck/rust-tyty.h (class DynamicObjectType): moved up

gcc/testsuite/ChangeLog:

* rust/execute/torture/issue-2180.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/backend/rust-compile-expr.cc
gcc/rust/backend/rust-compile-type.cc
gcc/rust/backend/rust-compile-type.h
gcc/rust/backend/rust-compile.cc
gcc/rust/backend/rust-tree.h
gcc/rust/typecheck/rust-tyty.cc
gcc/rust/typecheck/rust-tyty.h
gcc/testsuite/rust/execute/torture/issue-2180.rs [new file with mode: 0644]