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

Const check/promotion cleanup and sanity assertion #71198

Merged
merged 7 commits into from
Apr 23, 2020

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Apr 16, 2020

r? @RalfJung

This is just the part of #70042 (comment) that does not change behaviour

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 16, 2020
Comment on lines 1 to 2
// ignore-compare-mode-nll
// compile-flags: -Z borrowck=migrate
Copy link
Member

Choose a reason for hiding this comment

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

What is this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

idk, I just copied the test

Copy link
Member

Choose a reason for hiding this comment

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

Copied from where?
Also I thought borrowck=migrate is on its way out of the compiler, so I am surprised to see new tests for it (Cc @rust-lang/wg-compiler-nll)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Okay so the header is the same but the rest of the test is very different.

I still have no clue why this is testing what, and what it has to do with the rest of the PR.

Copy link
Member

@RalfJung RalfJung Apr 16, 2020

Choose a reason for hiding this comment

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

So the commit title is "Add test for passing promotion but failing compilation ".

But I don't entirely understand what that is for, doesn't that happen all the time? The delay_span_bug is for failing promotion but passing compilation, i.e., the exact opposite.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was originally for explicit promotion, so maybe it doesn't make sense anymore

@@ -61,11 +61,15 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> {

let def_id = src.def_id();

let mut rpo = traversal::reverse_postorder(body);
let (temps, all_candidates) = collect_temps_and_candidates(tcx, body, &mut rpo);
let read_only_body = read_only!(body);
Copy link
Member

Choose a reason for hiding this comment

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

What kind of strange hack is this?

Copy link
Member

@RalfJung RalfJung Apr 16, 2020

Choose a reason for hiding this comment

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

I found the read_only! macro definition but it seems undocumented.
I am calling it a hack because the macro looks like it could just be a method instead, so I am probably missing the reason why it is a macro (and the macro name is entirely unhelpful, not indicating it has anything to do with MIR bodies).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unrelated to this PR, but yea, this can likely become a method. I think the reason it's a macro is multiple refactorings after each other removing the need for the macro at some point

Copy link
Contributor

@ecstatic-morse ecstatic-morse Apr 16, 2020

Choose a reason for hiding this comment

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

I think it is a macro because it has a signature like fn(&mut self) -> &Self, which runs into a shortcoming of the borrow checker where the returned reference is not allowed to alias.

Copy link
Member

Choose a reason for hiding this comment

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

Well that would be a useful thing to have in a doc comment. ;)

Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

This LGTM, except for that new testcase which seems out-of-place to me.

@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 17, 2020

I removed the test commit

@bors r=RalfJung

@bors
Copy link
Contributor

bors commented Apr 17, 2020

📌 Commit 316a401 has been approved by RalfJung

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 17, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 18, 2020
…Jung

Const check/promotion cleanup and sanity assertion

r? @RalfJung

This is just the part of rust-lang#70042 (comment) that does not change behaviour
@bors
Copy link
Contributor

bors commented Apr 19, 2020

☔ The latest upstream changes (presumably #71306) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 19, 2020
@oli-obk
Copy link
Contributor Author

oli-obk commented Apr 23, 2020

rebased

@bors r=RalfJung

@bors
Copy link
Contributor

bors commented Apr 23, 2020

📌 Commit 4cdc31b has been approved by RalfJung

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 23, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2020
Rollup of 6 pull requests

Successful merges:

 - rust-lang#71005 (Reading from the return place is fine)
 - rust-lang#71198 (Const check/promotion cleanup and sanity assertion)
 - rust-lang#71396 (Improve E0308 error message wording again)
 - rust-lang#71452 (Remove outdated reference to interpreter snapshotting)
 - rust-lang#71454 (Inline some function docs in `core::ptr`)
 - rust-lang#71461 (Improve E0567 explanation)

Failed merges:

r? @ghost
@bors bors merged commit 629a613 into rust-lang:master Apr 23, 2020
@oli-obk oli-obk deleted the const_check_cleanup branch July 29, 2020 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants