-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
// ignore-compare-mode-nll | ||
// compile-flags: -Z borrowck=migrate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. ;)
There was a problem hiding this 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.
a50bc6b
to
316a401
Compare
I removed the test commit @bors r=RalfJung |
📌 Commit 316a401 has been approved by |
…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
☔ The latest upstream changes (presumably #71306) made this pull request unmergeable. Please resolve the merge conflicts. |
…g had content there before the current changes
This renaming was already done in some modules via import renaming. It's strictly used as a context, and it contains a `TyCtxt`.
316a401
to
4cdc31b
Compare
rebased @bors r=RalfJung |
📌 Commit 4cdc31b has been approved by |
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
r? @RalfJung
This is just the part of #70042 (comment) that does not change behaviour