|
1 |
| -use crate::build::scope::BreakableScope; |
| 1 | +use crate::build::scope::BreakableTarget; |
2 | 2 | use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
|
3 | 3 | use crate::hair::*;
|
4 | 4 | use rustc::middle::region;
|
@@ -98,70 +98,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
98 | 98 | block.unit()
|
99 | 99 | }
|
100 | 100 | ExprKind::Continue { label } => {
|
101 |
| - let BreakableScope { |
102 |
| - continue_block, |
103 |
| - region_scope, |
104 |
| - .. |
105 |
| - } = *this.find_breakable_scope(expr_span, label); |
106 |
| - let continue_block = continue_block |
107 |
| - .expect("Attempted to continue in non-continuable breakable block"); |
108 |
| - this.exit_scope( |
109 |
| - expr_span, |
110 |
| - (region_scope, source_info), |
111 |
| - block, |
112 |
| - continue_block, |
113 |
| - ); |
114 |
| - this.cfg.start_new_block().unit() |
| 101 | + this.break_scope(block, None, BreakableTarget::Continue(label), source_info) |
115 | 102 | }
|
116 | 103 | ExprKind::Break { label, value } => {
|
117 |
| - let (break_block, region_scope, destination) = { |
118 |
| - let BreakableScope { |
119 |
| - break_block, |
120 |
| - region_scope, |
121 |
| - ref break_destination, |
122 |
| - .. |
123 |
| - } = *this.find_breakable_scope(expr_span, label); |
124 |
| - (break_block, region_scope, break_destination.clone()) |
125 |
| - }; |
126 |
| - if let Some(value) = value { |
127 |
| - debug!("stmt_expr Break val block_context.push(SubExpr) : {:?}", expr2); |
128 |
| - this.block_context.push(BlockFrame::SubExpr); |
129 |
| - unpack!(block = this.into(&destination, block, value)); |
130 |
| - this.block_context.pop(); |
131 |
| - } else { |
132 |
| - this.cfg.push_assign_unit(block, source_info, &destination) |
133 |
| - } |
134 |
| - this.exit_scope(expr_span, (region_scope, source_info), block, break_block); |
135 |
| - this.cfg.start_new_block().unit() |
| 104 | + this.break_scope(block, value, BreakableTarget::Break(label), source_info) |
136 | 105 | }
|
137 | 106 | ExprKind::Return { value } => {
|
138 |
| - block = match value { |
139 |
| - Some(value) => { |
140 |
| - debug!("stmt_expr Return val block_context.push(SubExpr) : {:?}", expr2); |
141 |
| - this.block_context.push(BlockFrame::SubExpr); |
142 |
| - let result = unpack!( |
143 |
| - this.into( |
144 |
| - &Place::RETURN_PLACE, |
145 |
| - block, |
146 |
| - value |
147 |
| - ) |
148 |
| - ); |
149 |
| - this.block_context.pop(); |
150 |
| - result |
151 |
| - } |
152 |
| - None => { |
153 |
| - this.cfg.push_assign_unit( |
154 |
| - block, |
155 |
| - source_info, |
156 |
| - &Place::RETURN_PLACE, |
157 |
| - ); |
158 |
| - block |
159 |
| - } |
160 |
| - }; |
161 |
| - let region_scope = this.region_scope_of_return_scope(); |
162 |
| - let return_block = this.return_block(); |
163 |
| - this.exit_scope(expr_span, (region_scope, source_info), block, return_block); |
164 |
| - this.cfg.start_new_block().unit() |
| 107 | + this.break_scope(block, value, BreakableTarget::Return, source_info) |
165 | 108 | }
|
166 | 109 | ExprKind::InlineAsm {
|
167 | 110 | asm,
|
|
0 commit comments