Uh oh!
There was an error while loading. Please reload this page.
prune ill-conceived BTreeMap iter_mut assertion and test its mutability - #67459
Conversation
rust-highfive
commented
Dec 20, 2019
r? @cramertj (rust_highfive has picked a reviewer for you, use r? to override) |
cramertj
commented
Dec 20, 2019
I also wondered why so much effort went into setting up a slice for an immutable map, and there's only one genuine use: |
Centril
commented
Dec 21, 2019
cc @RalfJung |
ssomers
commented
Dec 22, 2019
Added more unit testing |
bors
commented
Dec 23, 2019
☔ The latest upstream changes (presumably #67540) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Back then I tried to keep the code as close as possible to how it was, so I didn't mess with the slices. But if we can get rid of them and thus get rid of the entirely awful |
There are at least two argument for keeping off my "radical" slice slashing experiment:
Still, I think it's probably best to keep the slices, but precondition out shared roots. It eliminates |
Uh oh!
There was an error while loading. Please reload this page.
RalfJung
commented
Dec 23, 2019
Well, and who's sure the current code is correct? ;)
I was wondering about the |
ssomers
commented
Dec 23, 2019
So it's not correct, and returning a temporary is the full story because in that case we're not going to mutate the key nor the key slice. |
ssomers
commented
Dec 23, 2019
No, no, no, that last point doesn't make sense either. Must reboot myself and find sanity. |
Sorry for the confusion. Slightly saner self says:
|
The new commit here only brings more and smarter testing, I haven't put back any assertion. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Should be "alignment and size check" now, I guess?
There was a problem hiding this comment.
I think it's clear enough. In my mind, it's about the "alignment" of the keys_start field, so both the alignment of the struct and the offset of the field within the struct (which we measure through struct size). I guess "alignment" is a stretch here, but "alignment and size" is a bit of an implementation detail.
There was a problem hiding this comment.
The check literally looks at alignment and size, so it seems odd to call it an "alignment check". And of course this is an implementation detail, we are knee-deep inside a private method's unsafe code here.
There was a problem hiding this comment.
I meant that the sentence that brings the important point across about compile-time vs. run-time checks shouldn't elaborate or repeat the steps too much.
In any case, I have now substantially rearranged points.
RalfJung
commented
Dec 26, 2019
The PR now seems fine to me, modulo nits. I assume you ran tests with debug assertions enabled?
I really like the simplest alternative, but why can that work? You have not gotten rid of a single caller of |
RalfJung
commented
Dec 26, 2019
I checked all the callers and indeed I propose we land this PR with the minimal changes to fix the panic. I feel confident in reviewing that. Then, could you open a follow-up PR that gets rid of |
Yes, though only on 64 bit. And I haven't done it with miri on the recent master - the old miri |
RalfJung
commented
Dec 26, 2019
Miri master should work with rustc master (and it definitely works with the commit recorded here). You might have to rebase your PR though to sync things up. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ssomers
commented
Dec 26, 2019
Meanwhile Miri and 32/64 bit Linux & Windows all pass |
RalfJung
commented
Dec 26, 2019
Looking good, thanks a lot! @bors r+ |
bors
commented
Dec 26, 2019
📌 Commit e3c814e has been approved by |
prune ill-conceived BTreeMap iter_mut assertion and test its mutability Proposal to deal with rust-lang#67438 (and I'm more sure now that this is the right thing to do). Passes testing with miri.
Rollup of 12 pull requests Successful merges: - #67112 (Refactor expression parsing thoroughly) - #67192 (Various const eval and pattern matching ICE fixes) - #67287 (typeck: note other end-point when checking range pats) - #67459 (prune ill-conceived BTreeMap iter_mut assertion and test its mutability) - #67576 (reuse `capacity` variable in slice::repeat) - #67602 (Use issue = "none" instead of "0" in intrinsics) - #67614 (Set callbacks globally) - #67617 (Remove `compiler_builtins_lib` documentation) - #67629 (Remove redundant link texts) - #67632 (Convert collapsed to shortcut reference links) - #67633 (Update .mailmap) - #67635 (Document safety of Path casting) Failed merges: r? @ghost
bors
commented
Dec 28, 2019
⌛ Testing commit e3c814e with merge 54d8ccd5c7c02f9bd56cfac8200c38e1fbcefa8d... |
rust-highfive
commented
Dec 28, 2019
Your PR failed (pretty log, 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 |
bors
commented
Dec 28, 2019
💔 Test failed - checks-azure |
RalfJung
commented
Dec 28, 2019
Seems spurious. @bors retry |
There's something still not quite right:
But also, since Miri confirms that doing this is fine, doesn't that mean that the effort in |
bors
commented
Dec 28, 2019
prune ill-conceived BTreeMap iter_mut assertion and test its mutability Proposal to deal with #67438 (and I'm more sure now that this is the right thing to do). Passes testing with miri.
bors
commented
Dec 28, 2019
☀️ Test successful - checks-azure |
Simplify into_key_slice_mut Remove a rare and tiny but superfluous run-time check from into_key_slice_mut. In rust-lang#67459, I wrote that "`get_mut` [...] does visit `into_key_slice_mut`" and that was wrong. No function that operates on a map that (still) has a shared root ever dives into `into_key_slice_mut`. So it's more clear to remove the (previously existing, and always incomplete) code it has for dealing with shared roots, as well as a petty performance improvement for those using exotically aligned key types. ~~Also, some testing of the `range` function initially added to rust-lang#67686 but hardly related.~~ r? @RalfJung
Proposal to deal with #67438 (and I'm more sure now that this is the right thing to do).
Passes testing with miri.