-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Simplify implementation of align_offset slightly #54534
Conversation
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
r? @SimonSapin |
I honestly have a hard time following the math in this code. Unfortunately it looks like the reviewers of the previous version in #50319 did too :/ |
I agree that the maths here are fairly complicated. It is fairly easy, however, to see that this PR keeps the code equivalence. First, consider that the branch removed is To prove the equivalence between the branch bodies consider that In that case:
and
are exactly the same. The rest of the changes are documentation tweaks which I’ve figured as part of writing a blog post about some of the operations involved here (which I’m writing specifically with an intention to make the code here clearer). I’m willing to keep this PR open until I publish the post, if that makes it easier for your conscience to approve this PR. |
ce16f0b
to
0b3e5eb
Compare
I blogged about the implementation. Hope that makes it easier to review this. |
Ping from triage @SimonSapin / @rust-lang/libs: This PR requires your review. |
I, like @SimonSapin, have no idea what these functions are doing and find it pretty hard to follow... This is a lang item though and doesn't really require libs team review, it seems like it's just an implementation detail. @nagisa do you know someone else who's familiar with this who can review? |
The only reason this is a language item is to make miri understand what kind of function this is (since miri has to handle raw pointers specially). Otherwise, it is just an implementation detail for the currently unstable library function Admittedly, this change is so minor that I’d be fine with not landing this if it ends up requiring somebody to spend a significant time in order to understand and review this code. I’ll leave the decision to close this PR up to you.
Alas, the bus factor for this implementation is 2 (me and the person on IRC who collaborated with me in implementing this and whose nick I’ve forgotten by now). I had hoped to rectify this to some extent with my blog post (which I’ve linked in one of the comments above). If you are interested in raising the bus factor (I’m sure all of you have better things to do), I’d be willing to answer any questions as they come up. Yet, I’d like to point out that understanding the whole algorithm is not necessary to review this PR. I already wrote about what the essence of this specific pull request does here. I’d like to also point out that this algorithm is tested by a fairly exhaustive test suite. These tests were the basis for accepting the initial code. I’m very confident that these tests would have caught any issues with the changes I’ve made in this PR. |
Ok well it sounds like you're pretty confident in these changes as well as the test coverage, and if it's primarily for an unstable API then it shouldn't be harmful to add in as well. @bors: r+ |
📌 Commit 0b3e5eb has been approved by |
That's a nice blog post! Might be worth adding a link to it from the code? (Keep in mind though that the post might disappear before the code does.) |
⌛ Testing commit 0b3e5eb with merge 013be4d6d216bfafbd2a8b337ce5a60872a6a8dd... |
💔 Test failed - status-travis |
Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
Looks very spurious to me. @bors retry |
…hton Simplify implementation of align_offset slightly
☀️ Test successful - status-appveyor, status-travis |
No description provided.