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

Apply the fix in #31 to the v0.10.x branch #37

Merged
merged 1 commit into from
Sep 8, 2024

Commits on Sep 8, 2024

  1. Stop creating references unnecessarily to compare pointers by-address

    The test `common::deque::basics` contains several lines that look like this:
    ```
    assert!(std::ptr::eq(head_d, unsafe { node1_ptr.as_ref() }));
    ```
    
    What is happening is that we assert that `head_c`, a reference, is equal
    by-address to `node1_ptr`, a `NonNull<_>`. However, the way we do this
    is by creating a reference, instead of using `as_ptr`.
    
    The current way has several downsides:
    * It requires an `unsafe` block. Comparing pointer addresses is safe so
      this should be unnecessary.
    * **It is unsound**, at least under Tree Borrows rules.
      The references created there violate the uniqueness of references/Boxes
      created internally in the `Deque`, which trips the `Deque` later when
      it tries to use these internally-held references.
    * It is unnecessary -- comparing the result of `as_ptr` works just the same,
      maybe even faster due to less intermediary methods.
    
    As such, the test should be updated to only use `as_ptr`. When done, it
    actually makes the tests pass under Tree Borrows.
    
    (cherry picked from commit af40a12)
    JoJoDeveloping authored and tatsuya6502 committed Sep 8, 2024
    Configuration menu
    Copy the full SHA
    df115b9 View commit details
    Browse the repository at this point in the history