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

Gc::from_raw: Rely only on documented guarantees to compute layout #125

Merged
merged 2 commits into from
Feb 9, 2021

Commits on Jan 30, 2021

  1. cargo fmt

    Signed-off-by: Anders Kaseorg <andersk@mit.edu>
    andersk committed Jan 30, 2021
    Configuration menu
    Copy the full SHA
    54ae933 View commit details
    Browse the repository at this point in the history
  2. Gc::from_raw: Rely only on documented guarantees to compute layout

    The claim “Because it is ?Sized, it will always be the last field in
    memory” was not reliable: the ?Sized type may in fact be Sized (which
    the compiler will know after monomorphization), and in any case, the
    language provides no guarantees about the layout of repr(Rust)
    structs.
    
    Switch GcBox to repr(C), and rewrite the layout computation based on
    Layout::extend, which has a documented guarantee to match the layout
    of repr(C) structs.
    
    (RcBox in the standard library is repr(C) for the same reason.)
    
    Signed-off-by: Anders Kaseorg <andersk@mit.edu>
    andersk committed Jan 30, 2021
    Configuration menu
    Copy the full SHA
    a2ad94a View commit details
    Browse the repository at this point in the history