-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Clean up MIR drop generation #61872
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
Clean up MIR drop generation #61872
Changes from all commits
62bec71
101a2f5
82a1a89
be23bd4
b86e675
3131427
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,20 +179,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |
// conduct the test, if necessary | ||
let body_block; | ||
if let Some(cond_expr) = opt_cond_expr { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. N.B. As part of implementing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should be fine, this is only a problem because fn while_loop(c: bool) {
while get_bool(c) {
if get_bool(c) {
break;
}
}
}
// What the above should probably expand to
fn exp_while_loop(c: bool) {
loop {
match get_bool(c) {
true => {
{if get_bool(c) {
break;
}}
continue;
}
_ => {}
}
break;
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool.
Specifically, the HIR lowering should likely be: 'label: while $cond $block ==> 'label: loop {
match DropTemps($cond) {
true => $block,
_ => break,
}
} (is there a particular reason you are using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's slightly closer to what the RFC specified. What you're suggesting is probably better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be unnecessary now with #61988. |
||
let loop_block_end; | ||
let cond = unpack!( | ||
loop_block_end = this.as_local_operand(loop_block, cond_expr) | ||
); | ||
body_block = this.cfg.start_new_block(); | ||
let term = | ||
TerminatorKind::if_(this.hir.tcx(), cond, body_block, exit_block); | ||
this.cfg.terminate(loop_block_end, source_info, term); | ||
let cond_expr = this.hir.mirror(cond_expr); | ||
let (true_block, false_block) | ||
= this.test_bool(loop_block, cond_expr, source_info); | ||
body_block = true_block; | ||
|
||
// if the test is false, there's no `break` to assign `destination`, so | ||
// we have to do it; this overwrites any `break`-assigned value but it's | ||
// always `()` anyway | ||
this.cfg | ||
.push_assign_unit(exit_block, source_info, destination); | ||
// we have to do it | ||
this.cfg.push_assign_unit(false_block, source_info, destination); | ||
this.cfg.terminate( | ||
false_block, | ||
source_info, | ||
TerminatorKind::Goto { target: exit_block }, | ||
); | ||
} else { | ||
body_block = this.cfg.start_new_block(); | ||
let diverge_cleanup = this.diverge_cleanup(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.