-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Work-around optimiser deficiencies in Range
iterator.
#24705
Conversation
The conditional mutation of the previous implementation resulted in poor code, making it unconditional makes `Range` less well behaved as an Iterator (but still legal) but also makes it fast. The intention is that this change will be reverted when rustc/LLVM handle the best-behaved implementation better. cc rust-lang#24660
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
Hm, I'm worried about cases where this causes overflow and you have debug assertions enabled (whereas the current code avoids the overflow). |
I believe that will only trigger after |
Oh yes, of course, my apologies for not reading the commentary more carefully. @bors: r+ |
📌 Commit 97b7c76 has been approved by |
⌛ Testing commit 97b7c76 with merge 4e9399c... |
💔 Test failed - auto-linux-64-nopt-t |
@huonw any idea about that build failure?
|
I was just about to report this (and suggest the same solution). Is this still being merged? |
I intend to get it merged, once I can debug the (reproducable) crash... absolutely no idea what is going on with it yet. 😢 |
I think I found it: range_inclusive (https://github.com/rust-lang/rust/blob/master/src/libcore/iter.rs#L2799-2808) won't work anymore due to the |
Unfortunately I think this is backwards incompatible as-is, so I'm going to close this in the same manner as #26390 |
This is really, really, really unfortunate. The inability of the existing implementation to optimize properly is kind of absurd. We should at least have something in the documentation indicating this until the codegen is fixed. |
The original test case that led to this PR optimizes well now. Are there
|
The conditional mutation of the previous implementation resulted in poor
code, making it unconditional makes
Range
less well behaved as anIterator (but still legal) but also makes it fast.
The intention is that this change will be reverted when rustc/LLVM
handle the best-behaved implementation better.
cc #24660