Skip to content

Commit ed2ffd1

Browse files
authored
Unrolled build for rust-lang#126981
Rollup merge of rust-lang#126981 - Zalathar:enums, r=Nadrieril Replace some magic booleans in match-lowering with enums This PR takes some boolean arguments used by the match-lowering code, and replaces them with dedicated enums that more clearly express their effect, while also making it much easier to find how each value is ultimately used.
2 parents ef3d6fd + ed07712 commit ed2ffd1

File tree

3 files changed

+150
-52
lines changed

3 files changed

+150
-52
lines changed

compiler/rustc_mir_build/src/build/block.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::build::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops};
12
use crate::build::ForGuard::OutsideGuard;
23
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
34
use rustc_middle::middle::region::Scope;
@@ -201,7 +202,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
201202
pattern,
202203
UserTypeProjections::none(),
203204
&mut |this, _, _, node, span, _, _| {
204-
this.storage_live_binding(block, node, span, OutsideGuard, true);
205+
this.storage_live_binding(
206+
block,
207+
node,
208+
span,
209+
OutsideGuard,
210+
ScheduleDrops::Yes,
211+
);
205212
},
206213
);
207214
let else_block_span = this.thir[*else_block].span;
@@ -213,8 +220,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
213220
pattern,
214221
None,
215222
initializer_span,
216-
false,
217-
true,
223+
DeclareLetBindings::No,
224+
EmitStorageLive::No,
218225
)
219226
});
220227
matching.and(failure)
@@ -291,7 +298,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
291298
pattern,
292299
UserTypeProjections::none(),
293300
&mut |this, _, _, node, span, _, _| {
294-
this.storage_live_binding(block, node, span, OutsideGuard, true);
301+
this.storage_live_binding(
302+
block,
303+
node,
304+
span,
305+
OutsideGuard,
306+
ScheduleDrops::Yes,
307+
);
295308
this.schedule_drop_for_binding(node, span, OutsideGuard);
296309
},
297310
)

compiler/rustc_mir_build/src/build/expr/into.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! See docs in build/expr/mod.rs
22
33
use crate::build::expr::category::{Category, RvalueFunc};
4+
use crate::build::matches::DeclareLetBindings;
45
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, NeedsTemporary};
56
use rustc_ast::InlineAsmOptions;
67
use rustc_data_structures::fx::FxHashMap;
@@ -86,7 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8687
cond,
8788
Some(condition_scope), // Temp scope
8889
source_info,
89-
true, // Declare `let` bindings normally
90+
DeclareLetBindings::Yes, // Declare `let` bindings normally
9091
));
9192

9293
// Lower the `then` arm into its block.
@@ -163,7 +164,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
163164
source_info,
164165
// This flag controls how inner `let` expressions are lowered,
165166
// but either way there shouldn't be any of those in here.
166-
true,
167+
DeclareLetBindings::LetNotPermitted,
167168
)
168169
});
169170
let (short_circuit, continuation, constant) = match op {

0 commit comments

Comments
 (0)