Uh oh!
There was an error while loading. Please reload this page.
Const qualification comments - #61492
Conversation
rust-highfive
commented
Jun 3, 2019
r? @zackmdavis (rust_highfive has picked a reviewer for you, use r? to override) |
zackmdavis
commented
Jun 3, 2019
r? @eddyb |
There was a problem hiding this comment.
Nope, that's irrelevant. The problem is promoting e.g. &AtomicUsize and then mutating it.
That is, uses of the promoted references must not be able to distinguish between the promoted and unpromoted case (ignoring pointer addresses).
There was a problem hiding this comment.
Well that's what I meant.^^
And also the part where any use of a const item must be equivalent to inlining its definition.
There was a problem hiding this comment.
I have expanded the description a bit, is this better?
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Not just functions though, I think for everything? Promotion still has to do something in const/static, it's just slightly different than at runtime.
There was a problem hiding this comment.
No idea, I just moved that comment up, I did not write it.^^
There was a problem hiding this comment.
There's a comment in the file though saying
// No need to do anything in constants and statics, as everything is "constant" anyway
// so promotion would be useless.
if self.mode != Mode::Static && self.mode != Mode::Const {
So it does seem to not do promotion the same way for statics and consts?
There was a problem hiding this comment.
This seems oddly specific - this is the original sole check, so comparing it to something newer seems off.
You could move the comment one line above and make it more about "any qualifications, except HasMutInterior (see above), disqualify from promotion".
There was a problem hiding this comment.
I don't think which check came first historically has any bearing here. Just because it grew that way doesn't mean that's the best way to explain it.
The other check is IMO clearly "more principled" by looking at the place where the side-effect actually occurs.
There was a problem hiding this comment.
I have adjusted the wording a bit.
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.
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.
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.
This comment has been minimized.
This comment has been minimized.
bors
commented
Jun 5, 2019
☔ The latest upstream changes (presumably #61548) made this pull request unmergeable. Please resolve the merge conflicts. |
6bb0760 to
dfa40d3Comparebors
commented
Jun 9, 2019
☔ The latest upstream changes (presumably #61653) made this pull request unmergeable. Please resolve the merge conflicts. |
96436e3 to
38c7f3eCompareRalfJung
commented
Jun 9, 2019
This is bitrotting. @eddyb could you have a look at my edits? |
eddyb
commented
Jun 10, 2019
@bors r+ |
bors
commented
Jun 10, 2019
📌 Commit 38c7f3e has been approved by |
bors
commented
Jun 10, 2019
☔ The latest upstream changes (presumably #61506) made this pull request unmergeable. Please resolve the merge conflicts. |
38c7f3e to
0edf46fCompareRalfJung
commented
Jun 10, 2019
Rebased. @bors r=eddyb |
bors
commented
Jun 10, 2019
📌 Commit 0edf46f has been approved by |
bors
commented
Jun 10, 2019
⌛ Testing commit 0edf46f with merge 0efa0a6a57bfe2ed3e05e02850f3c18d8747b767... |
bors
commented
Jun 10, 2019
💥 Test timed out |
RalfJung
commented
Jun 10, 2019
@bors retry |
bors
commented
Jun 11, 2019
bors
commented
Jun 11, 2019
☀️ Test successful - checks-travis, status-appveyor |
I extracted some const-qualif knowledge from @eddyb. This is my attempt to turn that into comments.
Cc @oli-obk@eddyb