Skip to content

Commit 6c39107

Browse files
committed
No need to re-establish temporaries
1 parent 5250a4b commit 6c39107

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

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

+1-33
Original file line numberDiff line numberDiff line change
@@ -990,17 +990,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
990990
}
991991
}
992992

993-
/// A temporary that must be set like `let temp = Deref::deref(&place)` after the candidate
994-
/// `pre_binding_block`. This is because fake edges prevent us from keeping the temporaries we set
995-
/// up while testing which branch to take.
996-
#[derive(Debug, Copy, Clone)]
997-
struct DerefTemporary<'tcx> {
998-
place: Place<'tcx>,
999-
temp: Place<'tcx>,
1000-
ty: Ty<'tcx>,
1001-
span: Span,
1002-
}
1003-
1004993
/// Data extracted from a pattern that doesn't affect which branch is taken. Collected during
1005994
/// pattern simplification and not mutated later.
1006995
#[derive(Debug, Clone, Default)]
@@ -1013,15 +1002,12 @@ struct PatternExtraData<'tcx> {
10131002

10141003
/// Types that must be asserted.
10151004
ascriptions: Vec<Ascription<'tcx>>,
1016-
1017-
/// Temporaries that must be set up in order.
1018-
deref_temps: Vec<DerefTemporary<'tcx>>,
10191005
}
10201006

10211007
impl<'tcx> PatternExtraData<'tcx> {
10221008
fn is_empty(&self) -> bool {
10231009
// FIXME(deref_patterns): can we merge trivial subcandidates that use deref patterns?
1024-
self.bindings.is_empty() && self.ascriptions.is_empty() && self.deref_temps.is_empty()
1010+
self.bindings.is_empty() && self.ascriptions.is_empty()
10251011
}
10261012
}
10271013

@@ -1048,7 +1034,6 @@ impl<'tcx, 'pat> FlatPat<'pat, 'tcx> {
10481034
span: pattern.span,
10491035
bindings: Vec::new(),
10501036
ascriptions: Vec::new(),
1051-
deref_temps: Vec::new(),
10521037
},
10531038
};
10541039
cx.simplify_match_pairs(&mut flat_pat.match_pairs, &mut flat_pat.extra_data);
@@ -2095,23 +2080,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20952080
block = fresh_block;
20962081
}
20972082

2098-
for d in collected_data.iter() {
2099-
for deref_call in d.deref_temps.iter() {
2100-
// Re-establish `Deref::deref` temporaries because false edges trick borrowck into
2101-
// believing they may not be initialized.
2102-
let next_block = self.cfg.start_new_block();
2103-
self.call_deref(
2104-
block,
2105-
next_block,
2106-
deref_call.place,
2107-
deref_call.ty,
2108-
deref_call.temp,
2109-
deref_call.span,
2110-
);
2111-
block = next_block;
2112-
}
2113-
}
2114-
21152083
self.ascribe_types(block, collected_data.iter().flat_map(|d| &d.ascriptions).cloned());
21162084

21172085
// rust-lang/rust#27282: The `autoref` business deserves some

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

+1-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//! sort of test: for example, testing which variant an enum is, or
1313
//! testing a value against a constant.
1414
15-
use crate::build::matches::{DerefTemporary, MatchPair, PatternExtraData, TestCase};
15+
use crate::build::matches::{MatchPair, PatternExtraData, TestCase};
1616
use crate::build::Builder;
1717

1818
use std::mem;
@@ -44,17 +44,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4444
// after any bindings in `pat`. This doesn't work for or-patterns: the current structure of
4545
// match lowering forces us to lower bindings inside or-patterns last.
4646
for mut match_pair in mem::take(match_pairs) {
47-
if let TestCase::Deref { temp } = &match_pair.test_case {
48-
// Re-establish these temporaries after matching the candidate in case we have
49-
// bindings that depend on them.
50-
extra_data.deref_temps.push(DerefTemporary {
51-
place: match_pair.place.to_place(self),
52-
temp: *temp,
53-
ty: match_pair.pattern.ty,
54-
span: match_pair.pattern.span,
55-
});
56-
}
57-
5847
self.simplify_match_pairs(&mut match_pair.subpairs, extra_data);
5948
if let TestCase::Irrefutable { binding, ascription } = match_pair.test_case {
6049
if let Some(binding) = binding {

0 commit comments

Comments
 (0)