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

Conversation

tatsuya6502
Copy link
Member

Fixes #32

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)
Copy link
Member Author

@tatsuya6502 tatsuya6502 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging.

@tatsuya6502 tatsuya6502 merged commit 0dce5da into v0.10.x Sep 8, 2024
27 of 28 checks passed
@tatsuya6502 tatsuya6502 linked an issue Sep 8, 2024 that may be closed by this pull request
@tatsuya6502 tatsuya6502 deleted the apply-pr31-to-v0.10.x branch September 8, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apply the fix in #31 to the v0.10.x branch too
2 participants