Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new ThinBox type for 1 stack pointer wide heap allocated trait objects #90066

Merged
merged 1 commit into from
Apr 9, 2022

Commits on Apr 8, 2022

  1. Add ThinBox type for 1 stack pointer sized heap allocated trait objects

    Relevant commit messages from squashed history in order:
    
    Add initial version of ThinBox
    
    update test to actually capture failure
    
    swap to middle ptr impl based on matthieu-m's design
    
    Fix stack overflow in debug impl
    
    The previous version would take a `&ThinBox<T>` and deref it once, which
    resulted in a no-op and the same type, which it would then print causing
    an endless recursion. I've switched to calling `deref` by name to let
    method resolution handle deref the correct number of times.
    
    I've also updated the Drop impl for good measure since it seemed like it
    could be falling prey to the same bug, and I'll be adding some tests to
    verify that the drop is happening correctly.
    
    add test to verify drop is behaving
    
    add doc examples and remove unnecessary Pointee bounds
    
    ThinBox: use NonNull
    
    ThinBox: tests for size
    
    Apply suggestions from code review
    
    Co-authored-by: Alphyr <47725341+a1phyr@users.noreply.github.com>
    
    use handle_alloc_error and fix drop signature
    
    update niche and size tests
    
    add cfg for allocating APIs
    
    check null before calculating offset
    
    add test for zst and trial usage
    
    prevent optimizer induced ub in drop and cleanup metadata gathering
    
    account for arbitrary size and alignment metadata
    
    Thank you nika and thomcc!
    
    Update library/alloc/src/boxed/thin.rs
    
    Co-authored-by: Josh Triplett <josh@joshtriplett.org>
    
    Update library/alloc/src/boxed/thin.rs
    
    Co-authored-by: Josh Triplett <josh@joshtriplett.org>
    yaahc and joshtriplett committed Apr 8, 2022
    Configuration menu
    Copy the full SHA
    a87a0d0 View commit details
    Browse the repository at this point in the history