Improve box - #4767
Merged
Merged
Conversation
Member
|
oh wait i see there is a base mr to this |
This patch introduces DST support for box, allowing it to correctly handle unsized types. It also implements the auto-deref mechanism for box. This ensures that method dispatch, indexing, and tuple field access work correctly. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (compile_box): Remove DST guard. (build_box_inner_ptr): Add fat pointer control. (CompileExpr::visit): Add auto-deref for box. (HIRCompileBase::resolve_deref_adjustment): Return fat or thin pointer. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Add auto-deref for box. * typecheck/rust-tyty.cc (ADTType::is_box): New function. * typecheck/rust-tyty.h (class BaseType): New declaration. gcc/testsuite/ChangeLog: * rust/execute/box-dispatch-1.rs: New test. * rust/execute/box-dispatch-2.rs: New test. * rust/execute/unsized-adt-size.rs: Format test. Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch implements the 'dispatch_from_dyn' lang item specifically for 'Box'. While there are other smart pointers and types that require this lang item for dynamic dispatch, they are omitted in this patch as they are not yet fully supported by the compiler. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): Handle Box receivers correctly during dynamic dispatch. * typecheck/rust-hir-dot-operator.cc (MethodResolver::try_hook): Extract the inner type of a Box to resolve trait methods. * util/rust-lang-item.cc (Rust::LangItem::lang_items): Register dispatch_from_dyn to the BiMap. * util/rust-lang-item.h (class LangItem): Add DISPATCH_FROM_DYN to the Kind enum. gcc/testsuite/ChangeLog: * rust/execute/box-dispatch-from-dyn.rs: New test. Signed-off-by: Enes Cevik <enes@nsvke.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch introduces DST support for box, allowing it to correctly
handle unsized types.
It also implements the auto-deref mechanism for box. This ensures that
method dispatch, indexing, and tuple field access work correctly.
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog:
This patch implements the 'dispatch_from_dyn' lang item specifically for
'Box'. While there are other smart pointers and types that require this
lang item for dynamic dispatch, they are omitted in this patch as they
are not yet fully supported by the compiler.
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: