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

Make pointer offset methods/intrinsics const #71500

Merged
merged 8 commits into from
May 30, 2020
Merged

Commits on May 25, 2020

  1. librustc_mir: Add support for const fn offset/arith_offset

    Miri's pointer_offset_inbounds implementation has been moved into
    librustc_mir as ptr_offset_inbounds (to avoid breaking miri on a
    nightly update). The comments have been slightly reworked to better
    match `offset`'s external documentation about what causes UB.
    
    The intrinsic implementations are taken directly from miri.
    
    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 25, 2020
    Configuration menu
    Copy the full SHA
    08df311 View commit details
    Browse the repository at this point in the history
  2. core: Make pointer offset methods "const fn"

    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 25, 2020
    Configuration menu
    Copy the full SHA
    9b3dfd8 View commit details
    Browse the repository at this point in the history
  3. test/ui/consts: Add tests for const ptr offsets

    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 25, 2020
    Configuration menu
    Copy the full SHA
    88a37a2 View commit details
    Browse the repository at this point in the history
  4. miri_unleached: We now allow offset in const fn

    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 25, 2020
    Configuration menu
    Copy the full SHA
    6b20f58 View commit details
    Browse the repository at this point in the history
  5. librustc_mir: Add back use statement

    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 25, 2020
    Configuration menu
    Copy the full SHA
    55577b4 View commit details
    Browse the repository at this point in the history

Commits on May 26, 2020

  1. librustc_middle: Add function for computing unsigned abs

    This is tricky to get right if we want to avoid panicking or wrapping.
    
    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 26, 2020
    Configuration menu
    Copy the full SHA
    6367b54 View commit details
    Browse the repository at this point in the history
  2. Add checks and tests for computing abs(offset_bytes)

    The previous code paniced if offset_bytes == i64::MIN. This commit:
      - Properly computes the absoulte value to avoid this panic
      - Adds a test for this edge case
    
    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 26, 2020
    Configuration menu
    Copy the full SHA
    71ef841 View commit details
    Browse the repository at this point in the history

Commits on May 28, 2020

  1. Add additional checks for isize overflow

    We now perform the correct checks even if the pointer size differs
    between the host and target.
    
    Signed-off-by: Joe Richey <joerichey@google.com>
    josephlr committed May 28, 2020
    Configuration menu
    Copy the full SHA
    7d5415b View commit details
    Browse the repository at this point in the history