Skip to content

Commit 806c5c1

Browse files
authored
Rollup merge of #126835 - Nadrieril:reify-decision-tree, r=matthewjasper
Simplifications in match lowering A series of small simplifications and deduplications in the MIR lowering of patterns. r? ````@matthewjasper````
2 parents dfa68f1 + beb1d35 commit 806c5c1

File tree

5 files changed

+316
-353
lines changed

5 files changed

+316
-353
lines changed

compiler/rustc_mir_build/src/build/block.rs

+31-32
Original file line numberDiff line numberDiff line change
@@ -189,38 +189,37 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
189189

190190
let initializer_span = this.thir[*initializer].span;
191191
let scope = (*init_scope, source_info);
192-
let failure = unpack!(
193-
block = this.in_scope(scope, *lint_level, |this| {
194-
this.declare_bindings(
195-
visibility_scope,
196-
remainder_span,
197-
pattern,
198-
None,
199-
Some((Some(&destination), initializer_span)),
200-
);
201-
this.visit_primary_bindings(
202-
pattern,
203-
UserTypeProjections::none(),
204-
&mut |this, _, _, node, span, _, _| {
205-
this.storage_live_binding(
206-
block,
207-
node,
208-
span,
209-
OutsideGuard,
210-
true,
211-
);
212-
},
213-
);
214-
this.ast_let_else(
215-
block,
216-
*initializer,
217-
initializer_span,
218-
*else_block,
219-
&last_remainder_scope,
220-
pattern,
221-
)
222-
})
223-
);
192+
let failure_and_block = this.in_scope(scope, *lint_level, |this| {
193+
this.declare_bindings(
194+
visibility_scope,
195+
remainder_span,
196+
pattern,
197+
None,
198+
Some((Some(&destination), initializer_span)),
199+
);
200+
this.visit_primary_bindings(
201+
pattern,
202+
UserTypeProjections::none(),
203+
&mut |this, _, _, node, span, _, _| {
204+
this.storage_live_binding(block, node, span, OutsideGuard, true);
205+
},
206+
);
207+
let else_block_span = this.thir[*else_block].span;
208+
let (matching, failure) =
209+
this.in_if_then_scope(last_remainder_scope, else_block_span, |this| {
210+
this.lower_let_expr(
211+
block,
212+
*initializer,
213+
pattern,
214+
None,
215+
initializer_span,
216+
false,
217+
true,
218+
)
219+
});
220+
matching.and(failure)
221+
});
222+
let failure = unpack!(block = failure_and_block);
224223
this.cfg.goto(failure, source_info, failure_entry);
225224

226225
if let Some(source_scope) = visibility_scope {

0 commit comments

Comments
 (0)