Skip to content

Commit b95b7b9

Browse files
NadrierilZalathar
authored andcommitted
Small dedup
1 parent 230832e commit b95b7b9

File tree

1 file changed

+15
-18
lines changed
  • compiler/rustc_mir_build/src/build/matches

1 file changed

+15
-18
lines changed

compiler/rustc_mir_build/src/build/matches/mod.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,14 +2073,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20732073
return self.cfg.start_new_block();
20742074
}
20752075

2076-
self.ascribe_types(
2077-
block,
2078-
parent_data
2079-
.iter()
2080-
.flat_map(|d| &d.ascriptions)
2081-
.cloned()
2082-
.chain(candidate.extra_data.ascriptions),
2083-
);
2076+
let ascriptions = parent_data
2077+
.iter()
2078+
.flat_map(|d| &d.ascriptions)
2079+
.cloned()
2080+
.chain(candidate.extra_data.ascriptions);
2081+
let bindings =
2082+
parent_data.iter().flat_map(|d| &d.bindings).chain(&candidate.extra_data.bindings);
2083+
2084+
self.ascribe_types(block, ascriptions);
20842085

20852086
// rust-lang/rust#27282: The `autoref` business deserves some
20862087
// explanation here.
@@ -2167,12 +2168,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
21672168
&& let Some(guard) = arm.guard
21682169
{
21692170
let tcx = self.tcx;
2170-
let bindings =
2171-
parent_data.iter().flat_map(|d| &d.bindings).chain(&candidate.extra_data.bindings);
21722171

21732172
self.bind_matched_candidate_for_guard(block, schedule_drops, bindings.clone());
2174-
let guard_frame =
2175-
GuardFrame { locals: bindings.map(|b| GuardFrameLocal::new(b.var_id)).collect() };
2173+
let guard_frame = GuardFrame {
2174+
locals: bindings.clone().map(|b| GuardFrameLocal::new(b.var_id)).collect(),
2175+
};
21762176
debug!("entering guard building context: {:?}", guard_frame);
21772177
self.guard_context.push(guard_frame);
21782178

@@ -2245,11 +2245,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22452245
// ```
22462246
//
22472247
// and that is clearly not correct.
2248-
let by_value_bindings = parent_data
2249-
.iter()
2250-
.flat_map(|d| &d.bindings)
2251-
.chain(&candidate.extra_data.bindings)
2252-
.filter(|binding| matches!(binding.binding_mode.0, ByRef::No));
2248+
let by_value_bindings =
2249+
bindings.filter(|binding| matches!(binding.binding_mode.0, ByRef::No));
22532250
// Read all of the by reference bindings to ensure that the
22542251
// place they refer to can't be modified by the guard.
22552252
for binding in by_value_bindings.clone() {
@@ -2273,7 +2270,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
22732270
self.bind_matched_candidate_for_arm_body(
22742271
block,
22752272
schedule_drops,
2276-
parent_data.iter().flat_map(|d| &d.bindings).chain(&candidate.extra_data.bindings),
2273+
bindings,
22772274
storages_alive,
22782275
);
22792276
block

0 commit comments

Comments
 (0)