1
Fork 0

Rollup merge of #127159 - Nadrieril:hide-candidate, r=matthewjasper

match lowering: Hide `Candidate` from outside the lowering algorithm

The internals of `Candidate` are tricky and a source of confusion. This PR makes it so we don't expose `Candidate`s outside the lowering algorithm. Now:
- false edges are handled in `lower_match_tree`;
- `lower_match_tree` takes a list of patterns as input;
- `lower_match_tree` returns a flat datastructure that contains only the necessary information.

r? ```@matthewjasper```
This commit is contained in:
Matthias Krüger 2024-07-31 23:20:10 +02:00 committed by GitHub
commit 19f6ff0655
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 1007 additions and 943 deletions

View file

@ -17,7 +17,6 @@ use rustc_span::symbol::Symbol;
use rustc_span::{BytePos, Pos, Span}; use rustc_span::{BytePos, Pos, Span};
use rustc_target::abi::VariantIdx; use rustc_target::abi::VariantIdx;
use tracing::{debug, instrument}; use tracing::{debug, instrument};
use util::visit_bindings;
use crate::build::expr::as_place::PlaceBuilder; use crate::build::expr::as_place::PlaceBuilder;
use crate::build::scope::DropKind; use crate::build::scope::DropKind;
@ -366,28 +365,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let scrutinee_place = let scrutinee_place =
unpack!(block = self.lower_scrutinee(block, scrutinee_id, scrutinee_span)); unpack!(block = self.lower_scrutinee(block, scrutinee_id, scrutinee_span));
let mut arm_candidates = self.create_match_candidates(&scrutinee_place, arms); let arms = arms.iter().map(|arm| &self.thir[*arm]);
let match_has_guard = arm_candidates.iter().any(|(_, candidate)| candidate.has_guard);
let mut candidates =
arm_candidates.iter_mut().map(|(_, candidate)| candidate).collect::<Vec<_>>();
let match_start_span = span.shrink_to_lo().to(scrutinee_span); let match_start_span = span.shrink_to_lo().to(scrutinee_span);
let patterns = arms
// The set of places that we are creating fake borrows of. If there are no match guards then .clone()
// we don't need any fake borrows, so don't track them. .map(|arm| {
let fake_borrow_temps: Vec<(Place<'tcx>, Local, FakeBorrowKind)> = if match_has_guard { let has_match_guard =
util::collect_fake_borrows(self, &candidates, scrutinee_span, scrutinee_place.base()) if arm.guard.is_some() { HasMatchGuard::Yes } else { HasMatchGuard::No };
} else { (&*arm.pattern, has_match_guard)
Vec::new() })
}; .collect();
let built_tree = self.lower_match_tree(
self.lower_match_tree(
block, block,
scrutinee_span, scrutinee_span,
&scrutinee_place, &scrutinee_place,
match_start_span, match_start_span,
&mut candidates, patterns,
false, false,
); );
@ -395,9 +388,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
destination, destination,
scrutinee_place, scrutinee_place,
scrutinee_span, scrutinee_span,
arm_candidates, arms,
built_tree,
self.source_info(span), self.source_info(span),
fake_borrow_temps,
) )
} }
@ -417,51 +410,29 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block.and(scrutinee_place_builder) block.and(scrutinee_place_builder)
} }
/// Create the initial `Candidate`s for a `match` expression.
fn create_match_candidates<'pat>(
&mut self,
scrutinee: &PlaceBuilder<'tcx>,
arms: &'pat [ArmId],
) -> Vec<(&'pat Arm<'tcx>, Candidate<'pat, 'tcx>)>
where
'a: 'pat,
{
// Assemble the initial list of candidates. These top-level candidates
// are 1:1 with the original match arms, but other parts of match
// lowering also introduce subcandidates (for subpatterns), and will
// also flatten candidates in some cases. So in general a list of
// candidates does _not_ necessarily correspond to a list of arms.
arms.iter()
.copied()
.map(|arm| {
let arm = &self.thir[arm];
let arm_has_guard = arm.guard.is_some();
let arm_candidate =
Candidate::new(scrutinee.clone(), &arm.pattern, arm_has_guard, self);
(arm, arm_candidate)
})
.collect()
}
/// Lower the bindings, guards and arm bodies of a `match` expression. /// Lower the bindings, guards and arm bodies of a `match` expression.
/// ///
/// The decision tree should have already been created /// The decision tree should have already been created
/// (by [Builder::lower_match_tree]). /// (by [Builder::lower_match_tree]).
/// ///
/// `outer_source_info` is the SourceInfo for the whole match. /// `outer_source_info` is the SourceInfo for the whole match.
fn lower_match_arms( fn lower_match_arms<'pat>(
&mut self, &mut self,
destination: Place<'tcx>, destination: Place<'tcx>,
scrutinee_place_builder: PlaceBuilder<'tcx>, scrutinee_place_builder: PlaceBuilder<'tcx>,
scrutinee_span: Span, scrutinee_span: Span,
arm_candidates: Vec<(&'_ Arm<'tcx>, Candidate<'_, 'tcx>)>, arms: impl IntoIterator<Item = &'pat Arm<'tcx>>,
built_match_tree: BuiltMatchTree<'tcx>,
outer_source_info: SourceInfo, outer_source_info: SourceInfo,
fake_borrow_temps: Vec<(Place<'tcx>, Local, FakeBorrowKind)>, ) -> BlockAnd<()>
) -> BlockAnd<()> { where
let arm_end_blocks: Vec<BasicBlock> = arm_candidates 'tcx: 'pat,
{
let arm_end_blocks: Vec<BasicBlock> = arms
.into_iter() .into_iter()
.map(|(arm, candidate)| { .zip(built_match_tree.branches)
debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); .map(|(arm, branch)| {
debug!("lowering arm {:?}\ncorresponding branch = {:?}", arm, branch);
let arm_source_info = self.source_info(arm.span); let arm_source_info = self.source_info(arm.span);
let arm_scope = (arm.scope, arm_source_info); let arm_scope = (arm.scope, arm_source_info);
@ -494,8 +465,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let arm_block = this.bind_pattern( let arm_block = this.bind_pattern(
outer_source_info, outer_source_info,
candidate, branch,
&fake_borrow_temps, &built_match_tree.fake_borrow_temps,
scrutinee_span, scrutinee_span,
Some((arm, match_scope)), Some((arm, match_scope)),
EmitStorageLive::Yes, EmitStorageLive::Yes,
@ -548,18 +519,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
fn bind_pattern( fn bind_pattern(
&mut self, &mut self,
outer_source_info: SourceInfo, outer_source_info: SourceInfo,
candidate: Candidate<'_, 'tcx>, branch: MatchTreeBranch<'tcx>,
fake_borrow_temps: &[(Place<'tcx>, Local, FakeBorrowKind)], fake_borrow_temps: &[(Place<'tcx>, Local, FakeBorrowKind)],
scrutinee_span: Span, scrutinee_span: Span,
arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>, arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>,
emit_storage_live: EmitStorageLive, emit_storage_live: EmitStorageLive,
) -> BasicBlock { ) -> BasicBlock {
if candidate.subcandidates.is_empty() { if branch.sub_branches.len() == 1 {
// Avoid generating another `BasicBlock` when we only have one let [sub_branch] = branch.sub_branches.try_into().unwrap();
// candidate. // Avoid generating another `BasicBlock` when we only have one sub branch.
self.bind_and_guard_matched_candidate( self.bind_and_guard_matched_candidate(
candidate, sub_branch,
&[],
fake_borrow_temps, fake_borrow_temps,
scrutinee_span, scrutinee_span,
arm_match_scope, arm_match_scope,
@ -587,35 +557,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// We keep a stack of all of the bindings and type ascriptions // We keep a stack of all of the bindings and type ascriptions
// from the parent candidates that we visit, that also need to // from the parent candidates that we visit, that also need to
// be bound for each candidate. // be bound for each candidate.
traverse_candidate( for sub_branch in branch.sub_branches {
candidate, if let Some(arm) = arm {
&mut Vec::new(), self.clear_top_scope(arm.scope);
&mut |leaf_candidate, parent_data| { }
if let Some(arm) = arm { let binding_end = self.bind_and_guard_matched_candidate(
self.clear_top_scope(arm.scope); sub_branch,
} fake_borrow_temps,
let binding_end = self.bind_and_guard_matched_candidate( scrutinee_span,
leaf_candidate, arm_match_scope,
parent_data, schedule_drops,
fake_borrow_temps, emit_storage_live,
scrutinee_span, );
arm_match_scope, if arm.is_none() {
schedule_drops, schedule_drops = ScheduleDrops::No;
emit_storage_live, }
); self.cfg.goto(binding_end, outer_source_info, target_block);
if arm.is_none() { }
schedule_drops = ScheduleDrops::No;
}
self.cfg.goto(binding_end, outer_source_info, target_block);
},
|inner_candidate, parent_data| {
parent_data.push(inner_candidate.extra_data);
inner_candidate.subcandidates.into_iter()
},
|parent_data| {
parent_data.pop();
},
);
target_block target_block
} }
@ -725,7 +683,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
initializer: PlaceBuilder<'tcx>, initializer: PlaceBuilder<'tcx>,
set_match_place: bool, set_match_place: bool,
) -> BlockAnd<()> { ) -> BlockAnd<()> {
let mut candidate = Candidate::new(initializer.clone(), irrefutable_pat, false, self); let built_tree = self.lower_match_tree(
block,
irrefutable_pat.span,
&initializer,
irrefutable_pat.span,
vec![(irrefutable_pat, HasMatchGuard::No)],
false,
);
let [branch] = built_tree.branches.try_into().unwrap();
// For matches and function arguments, the place that is being matched // For matches and function arguments, the place that is being matched
// can be set when creating the variables. But the place for // can be set when creating the variables. But the place for
@ -746,7 +712,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// }; // };
// ``` // ```
if let Some(place) = initializer.try_to_place(self) { if let Some(place) = initializer.try_to_place(self) {
visit_bindings(&[&mut candidate], |binding: &Binding<'_>| { // Because or-alternatives bind the same variables, we only explore the first one.
let first_sub_branch = branch.sub_branches.first().unwrap();
for binding in &first_sub_branch.bindings {
let local = self.var_local_id(binding.var_id, OutsideGuard); let local = self.var_local_id(binding.var_id, OutsideGuard);
if let LocalInfo::User(BindingForm::Var(VarBindingForm { if let LocalInfo::User(BindingForm::Var(VarBindingForm {
opt_match_place: Some((ref mut match_place, _)), opt_match_place: Some((ref mut match_place, _)),
@ -757,21 +725,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
} else { } else {
bug!("Let binding to non-user variable.") bug!("Let binding to non-user variable.")
}; };
}); }
} }
} }
self.lower_match_tree(
block,
irrefutable_pat.span,
&initializer,
irrefutable_pat.span,
&mut [&mut candidate],
false,
);
self.bind_pattern( self.bind_pattern(
self.source_info(irrefutable_pat.span), self.source_info(irrefutable_pat.span),
candidate, branch,
&[], &[],
irrefutable_pat.span, irrefutable_pat.span,
None, None,
@ -1152,20 +1112,21 @@ struct Candidate<'pat, 'tcx> {
/// The earliest block that has only candidates >= this one as descendents. Used for false /// The earliest block that has only candidates >= this one as descendents. Used for false
/// edges, see the doc for [`Builder::match_expr`]. /// edges, see the doc for [`Builder::match_expr`].
false_edge_start_block: Option<BasicBlock>, false_edge_start_block: Option<BasicBlock>,
/// The `false_edge_start_block` of the next candidate.
next_candidate_start_block: Option<BasicBlock>,
} }
impl<'tcx, 'pat> Candidate<'pat, 'tcx> { impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
fn new( fn new(
place: PlaceBuilder<'tcx>, place: PlaceBuilder<'tcx>,
pattern: &'pat Pat<'tcx>, pattern: &'pat Pat<'tcx>,
has_guard: bool, has_guard: HasMatchGuard,
cx: &mut Builder<'_, 'tcx>, cx: &mut Builder<'_, 'tcx>,
) -> Self { ) -> Self {
// Use `FlatPat` to build simplified match pairs, then immediately // Use `FlatPat` to build simplified match pairs, then immediately
// incorporate them into a new candidate. // incorporate them into a new candidate.
Self::from_flat_pat(FlatPat::new(place, pattern, cx), has_guard) Self::from_flat_pat(
FlatPat::new(place, pattern, cx),
matches!(has_guard, HasMatchGuard::Yes),
)
} }
/// Incorporates an already-simplified [`FlatPat`] into a new candidate. /// Incorporates an already-simplified [`FlatPat`] into a new candidate.
@ -1179,7 +1140,6 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
otherwise_block: None, otherwise_block: None,
pre_binding_block: None, pre_binding_block: None,
false_edge_start_block: None, false_edge_start_block: None,
next_candidate_start_block: None,
} }
} }
@ -1199,6 +1159,17 @@ impl<'tcx, 'pat> Candidate<'pat, 'tcx> {
|_| {}, |_| {},
); );
} }
/// Visit the leaf candidates in reverse order.
fn visit_leaves_rev<'a>(&'a mut self, mut visit_leaf: impl FnMut(&'a mut Self)) {
traverse_candidate(
self,
&mut (),
&mut move |c, _| visit_leaf(c),
move |c, _| c.subcandidates.iter_mut().rev(),
|_| {},
);
}
} }
/// A depth-first traversal of the `Candidate` and all of its recursive /// A depth-first traversal of the `Candidate` and all of its recursive
@ -1409,12 +1380,114 @@ pub(crate) struct ArmHasGuard(pub(crate) bool);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Main matching algorithm // Main matching algorithm
/// A sub-branch in the output of match lowering. Match lowering has generated MIR code that will
/// branch to `success_block` when the matched value matches the corresponding pattern. If there is
/// a guard, its failure must continue to `otherwise_block`, which will resume testing patterns.
#[derive(Debug)]
struct MatchTreeSubBranch<'tcx> {
span: Span,
/// The block that is branched to if the corresponding subpattern matches.
success_block: BasicBlock,
/// The block to branch to if this arm had a guard and the guard fails.
otherwise_block: BasicBlock,
/// The bindings to set up in this sub-branch.
bindings: Vec<Binding<'tcx>>,
/// The ascriptions to set up in this sub-branch.
ascriptions: Vec<Ascription<'tcx>>,
/// Whether the sub-branch corresponds to a never pattern.
is_never: bool,
}
/// A branch in the output of match lowering.
#[derive(Debug)]
struct MatchTreeBranch<'tcx> {
sub_branches: Vec<MatchTreeSubBranch<'tcx>>,
}
/// The result of generating MIR for a pattern-matching expression. Each input branch/arm/pattern
/// gives rise to an output `MatchTreeBranch`. If one of the patterns matches, we branch to the
/// corresponding `success_block`. If none of the patterns matches, we branch to `otherwise_block`.
///
/// Each branch is made of one of more sub-branches, corresponding to or-patterns. E.g.
/// ```ignore(illustrative)
/// match foo {
/// (x, false) | (false, x) => {}
/// (true, true) => {}
/// }
/// ```
/// Here the first arm gives the first `MatchTreeBranch`, which has two sub-branches, one for each
/// alternative of the or-pattern. They are kept separate because each needs to bind `x` to a
/// different place.
#[derive(Debug)]
struct BuiltMatchTree<'tcx> {
branches: Vec<MatchTreeBranch<'tcx>>,
otherwise_block: BasicBlock,
/// If any of the branches had a guard, we collect here the places and locals to fakely borrow
/// to ensure match guards can't modify the values as we match them. For more details, see
/// [`util::collect_fake_borrows`].
fake_borrow_temps: Vec<(Place<'tcx>, Local, FakeBorrowKind)>,
}
impl<'tcx> MatchTreeSubBranch<'tcx> {
fn from_sub_candidate(
candidate: Candidate<'_, 'tcx>,
parent_data: &Vec<PatternExtraData<'tcx>>,
) -> Self {
debug_assert!(candidate.match_pairs.is_empty());
MatchTreeSubBranch {
span: candidate.extra_data.span,
success_block: candidate.pre_binding_block.unwrap(),
otherwise_block: candidate.otherwise_block.unwrap(),
bindings: parent_data
.iter()
.flat_map(|d| &d.bindings)
.chain(&candidate.extra_data.bindings)
.cloned()
.collect(),
ascriptions: parent_data
.iter()
.flat_map(|d| &d.ascriptions)
.cloned()
.chain(candidate.extra_data.ascriptions)
.collect(),
is_never: candidate.extra_data.is_never,
}
}
}
impl<'tcx> MatchTreeBranch<'tcx> {
fn from_candidate(candidate: Candidate<'_, 'tcx>) -> Self {
let mut sub_branches = Vec::new();
traverse_candidate(
candidate,
&mut Vec::new(),
&mut |candidate: Candidate<'_, '_>, parent_data: &mut Vec<PatternExtraData<'_>>| {
sub_branches.push(MatchTreeSubBranch::from_sub_candidate(candidate, parent_data));
},
|inner_candidate, parent_data| {
parent_data.push(inner_candidate.extra_data);
inner_candidate.subcandidates.into_iter()
},
|parent_data| {
parent_data.pop();
},
);
MatchTreeBranch { sub_branches }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum HasMatchGuard {
Yes,
No,
}
impl<'a, 'tcx> Builder<'a, 'tcx> { impl<'a, 'tcx> Builder<'a, 'tcx> {
/// The entrypoint of the matching algorithm. Create the decision tree for the match expression, /// The entrypoint of the matching algorithm. Create the decision tree for the match expression,
/// starting from `block`. /// starting from `block`.
/// ///
/// Modifies `candidates` to store the bindings and type ascriptions for /// `patterns` is a list of patterns, one for each arm. The associated boolean indicates whether
/// that candidate. /// the arm has a guard.
/// ///
/// `refutable` indicates whether the candidate list is refutable (for `if let` and `let else`) /// `refutable` indicates whether the candidate list is refutable (for `if let` and `let else`)
/// or not (for `let` and `match`). In the refutable case we return the block to which we branch /// or not (for `let` and `match`). In the refutable case we return the block to which we branch
@ -1425,31 +1498,76 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
scrutinee_span: Span, scrutinee_span: Span,
scrutinee_place_builder: &PlaceBuilder<'tcx>, scrutinee_place_builder: &PlaceBuilder<'tcx>,
match_start_span: Span, match_start_span: Span,
candidates: &mut [&mut Candidate<'pat, 'tcx>], patterns: Vec<(&'pat Pat<'tcx>, HasMatchGuard)>,
refutable: bool, refutable: bool,
) -> BasicBlock { ) -> BuiltMatchTree<'tcx>
// This will generate code to test scrutinee_place and branch to the appropriate arm block. where
// See the doc comment on `match_candidates` for why we have an otherwise block. 'tcx: 'pat,
let otherwise_block = {
self.match_candidates(match_start_span, scrutinee_span, block, candidates); // Assemble the initial list of candidates. These top-level candidates are 1:1 with the
// input patterns, but other parts of match lowering also introduce subcandidates (for
// sub-or-patterns). So inside the algorithm, the candidates list may not correspond to
// match arms directly.
let mut candidates: Vec<Candidate<'_, '_>> = patterns
.into_iter()
.map(|(pat, has_guard)| {
Candidate::new(scrutinee_place_builder.clone(), pat, has_guard, self)
})
.collect();
// Link each leaf candidate to the `false_edge_start_block` of the next one. let fake_borrow_temps = util::collect_fake_borrows(
let mut previous_candidate: Option<&mut Candidate<'_, '_>> = None; self,
for candidate in candidates { &candidates,
candidate.visit_leaves(|leaf_candidate| { scrutinee_span,
if let Some(ref mut prev) = previous_candidate { scrutinee_place_builder.base(),
assert!(leaf_candidate.false_edge_start_block.is_some()); );
prev.next_candidate_start_block = leaf_candidate.false_edge_start_block;
// This will generate code to test scrutinee_place and branch to the appropriate arm block.
// If none of the arms match, we branch to `otherwise_block`. When lowering a `match`
// expression, exhaustiveness checking ensures that this block is unreachable.
let mut candidate_refs = candidates.iter_mut().collect::<Vec<_>>();
let otherwise_block =
self.match_candidates(match_start_span, scrutinee_span, block, &mut candidate_refs);
// Set up false edges so that the borrow-checker cannot make use of the specific CFG we
// generated. We falsely branch from each candidate to the one below it to make it as if we
// were testing match branches one by one in order. In the refutable case we also want a
// false edge to the final failure block.
let mut next_candidate_start_block = if refutable { Some(otherwise_block) } else { None };
for candidate in candidates.iter_mut().rev() {
let has_guard = candidate.has_guard;
candidate.visit_leaves_rev(|leaf_candidate| {
if let Some(next_candidate_start_block) = next_candidate_start_block {
let source_info = self.source_info(leaf_candidate.extra_data.span);
// Falsely branch to `next_candidate_start_block` before reaching pre_binding.
let old_pre_binding = leaf_candidate.pre_binding_block.unwrap();
let new_pre_binding = self.cfg.start_new_block();
self.false_edges(
old_pre_binding,
new_pre_binding,
next_candidate_start_block,
source_info,
);
leaf_candidate.pre_binding_block = Some(new_pre_binding);
if has_guard {
// Falsely branch to `next_candidate_start_block` also if the guard fails.
let new_otherwise = self.cfg.start_new_block();
let old_otherwise = leaf_candidate.otherwise_block.unwrap();
self.false_edges(
new_otherwise,
old_otherwise,
next_candidate_start_block,
source_info,
);
leaf_candidate.otherwise_block = Some(new_otherwise);
}
} }
previous_candidate = Some(leaf_candidate); assert!(leaf_candidate.false_edge_start_block.is_some());
next_candidate_start_block = leaf_candidate.false_edge_start_block;
}); });
} }
if refutable { if !refutable {
// In refutable cases there's always at least one candidate, and we want a false edge to
// the failure block.
previous_candidate.as_mut().unwrap().next_candidate_start_block = Some(otherwise_block)
} else {
// Match checking ensures `otherwise_block` is actually unreachable in irrefutable // Match checking ensures `otherwise_block` is actually unreachable in irrefutable
// cases. // cases.
let source_info = self.source_info(scrutinee_span); let source_info = self.source_info(scrutinee_span);
@ -1479,7 +1597,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.cfg.terminate(otherwise_block, source_info, TerminatorKind::Unreachable); self.cfg.terminate(otherwise_block, source_info, TerminatorKind::Unreachable);
} }
otherwise_block BuiltMatchTree {
branches: candidates.into_iter().map(MatchTreeBranch::from_candidate).collect(),
otherwise_block,
fake_borrow_temps,
}
} }
/// The main match algorithm. It begins with a set of candidates `candidates` and has the job of /// The main match algorithm. It begins with a set of candidates `candidates` and has the job of
@ -2229,17 +2351,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
) -> BlockAnd<()> { ) -> BlockAnd<()> {
let expr_span = self.thir[expr_id].span; let expr_span = self.thir[expr_id].span;
let scrutinee = unpack!(block = self.lower_scrutinee(block, expr_id, expr_span)); let scrutinee = unpack!(block = self.lower_scrutinee(block, expr_id, expr_span));
let mut candidate = Candidate::new(scrutinee.clone(), pat, false, self); let built_tree = self.lower_match_tree(
let otherwise_block = self.lower_match_tree(
block, block,
expr_span, expr_span,
&scrutinee, &scrutinee,
pat.span, pat.span,
&mut [&mut candidate], vec![(pat, HasMatchGuard::No)],
true, true,
); );
let [branch] = built_tree.branches.try_into().unwrap();
self.break_for_else(otherwise_block, self.source_info(expr_span)); self.break_for_else(built_tree.otherwise_block, self.source_info(expr_span));
match declare_let_bindings { match declare_let_bindings {
DeclareLetBindings::Yes => { DeclareLetBindings::Yes => {
@ -2261,7 +2383,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let success = self.bind_pattern( let success = self.bind_pattern(
self.source_info(pat.span), self.source_info(pat.span),
candidate, branch,
&[], &[],
expr_span, expr_span,
None, None,
@ -2269,7 +2391,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
); );
// If branch coverage is enabled, record this branch. // If branch coverage is enabled, record this branch.
self.visit_coverage_conditional_let(pat, success, otherwise_block); self.visit_coverage_conditional_let(pat, success, built_tree.otherwise_block);
success.unit() success.unit()
} }
@ -2282,52 +2404,28 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Note: we do not check earlier that if there is a guard, /// Note: we do not check earlier that if there is a guard,
/// there cannot be move bindings. We avoid a use-after-move by only /// there cannot be move bindings. We avoid a use-after-move by only
/// moving the binding once the guard has evaluated to true (see below). /// moving the binding once the guard has evaluated to true (see below).
fn bind_and_guard_matched_candidate<'pat>( fn bind_and_guard_matched_candidate(
&mut self, &mut self,
candidate: Candidate<'pat, 'tcx>, sub_branch: MatchTreeSubBranch<'tcx>,
parent_data: &[PatternExtraData<'tcx>],
fake_borrows: &[(Place<'tcx>, Local, FakeBorrowKind)], fake_borrows: &[(Place<'tcx>, Local, FakeBorrowKind)],
scrutinee_span: Span, scrutinee_span: Span,
arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>, arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>,
schedule_drops: ScheduleDrops, schedule_drops: ScheduleDrops,
emit_storage_live: EmitStorageLive, emit_storage_live: EmitStorageLive,
) -> BasicBlock { ) -> BasicBlock {
debug!("bind_and_guard_matched_candidate(candidate={:?})", candidate); debug!("bind_and_guard_matched_candidate(subbranch={:?})", sub_branch);
debug_assert!(candidate.match_pairs.is_empty()); let block = sub_branch.success_block;
let candidate_source_info = self.source_info(candidate.extra_data.span); if sub_branch.is_never {
let mut block = candidate.pre_binding_block.unwrap();
if candidate.next_candidate_start_block.is_some() {
let fresh_block = self.cfg.start_new_block();
self.false_edges(
block,
fresh_block,
candidate.next_candidate_start_block,
candidate_source_info,
);
block = fresh_block;
}
if candidate.extra_data.is_never {
// This arm has a dummy body, we don't need to generate code for it. `block` is already // This arm has a dummy body, we don't need to generate code for it. `block` is already
// unreachable (except via false edge). // unreachable (except via false edge).
let source_info = self.source_info(candidate.extra_data.span); let source_info = self.source_info(sub_branch.span);
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable); self.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
return self.cfg.start_new_block(); return self.cfg.start_new_block();
} }
let ascriptions = parent_data self.ascribe_types(block, sub_branch.ascriptions);
.iter()
.flat_map(|d| &d.ascriptions)
.cloned()
.chain(candidate.extra_data.ascriptions);
let bindings =
parent_data.iter().flat_map(|d| &d.bindings).chain(&candidate.extra_data.bindings);
self.ascribe_types(block, ascriptions);
// Lower an instance of the arm guard (if present) for this candidate, // Lower an instance of the arm guard (if present) for this candidate,
// and then perform bindings for the arm body. // and then perform bindings for the arm body.
@ -2338,9 +2436,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// Bindings for guards require some extra handling to automatically // Bindings for guards require some extra handling to automatically
// insert implicit references/dereferences. // insert implicit references/dereferences.
self.bind_matched_candidate_for_guard(block, schedule_drops, bindings.clone()); self.bind_matched_candidate_for_guard(
block,
schedule_drops,
sub_branch.bindings.iter(),
);
let guard_frame = GuardFrame { let guard_frame = GuardFrame {
locals: bindings.clone().map(|b| GuardFrameLocal::new(b.var_id)).collect(), locals: sub_branch
.bindings
.iter()
.map(|b| GuardFrameLocal::new(b.var_id))
.collect(),
}; };
debug!("entering guard building context: {:?}", guard_frame); debug!("entering guard building context: {:?}", guard_frame);
self.guard_context.push(guard_frame); self.guard_context.push(guard_frame);
@ -2376,17 +2482,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.cfg.push_fake_read(post_guard_block, guard_end, cause, Place::from(temp)); self.cfg.push_fake_read(post_guard_block, guard_end, cause, Place::from(temp));
} }
let otherwise_block = candidate.otherwise_block.unwrap_or_else(|| { self.cfg.goto(otherwise_post_guard_block, source_info, sub_branch.otherwise_block);
let unreachable = self.cfg.start_new_block();
self.cfg.terminate(unreachable, source_info, TerminatorKind::Unreachable);
unreachable
});
self.false_edges(
otherwise_post_guard_block,
otherwise_block,
candidate.next_candidate_start_block,
source_info,
);
// We want to ensure that the matched candidates are bound // We want to ensure that the matched candidates are bound
// after we have confirmed this candidate *and* any // after we have confirmed this candidate *and* any
@ -2414,8 +2510,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// ``` // ```
// //
// and that is clearly not correct. // and that is clearly not correct.
let by_value_bindings = let by_value_bindings = sub_branch
bindings.filter(|binding| matches!(binding.binding_mode.0, ByRef::No)); .bindings
.iter()
.filter(|binding| matches!(binding.binding_mode.0, ByRef::No));
// Read all of the by reference bindings to ensure that the // Read all of the by reference bindings to ensure that the
// place they refer to can't be modified by the guard. // place they refer to can't be modified by the guard.
for binding in by_value_bindings.clone() { for binding in by_value_bindings.clone() {
@ -2443,7 +2541,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.bind_matched_candidate_for_arm_body( self.bind_matched_candidate_for_arm_body(
block, block,
schedule_drops, schedule_drops,
bindings, sub_branch.bindings.iter(),
emit_storage_live, emit_storage_live,
); );
block block

View file

@ -1,5 +1,3 @@
use std::marker::PhantomData;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_middle::mir::*; use rustc_middle::mir::*;
use rustc_middle::ty::Ty; use rustc_middle::ty::Ty;
@ -18,18 +16,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
&mut self, &mut self,
from_block: BasicBlock, from_block: BasicBlock,
real_target: BasicBlock, real_target: BasicBlock,
imaginary_target: Option<BasicBlock>, imaginary_target: BasicBlock,
source_info: SourceInfo, source_info: SourceInfo,
) { ) {
match imaginary_target { if imaginary_target != real_target {
Some(target) if target != real_target => { self.cfg.terminate(
self.cfg.terminate( from_block,
from_block, source_info,
source_info, TerminatorKind::FalseEdge { real_target, imaginary_target },
TerminatorKind::FalseEdge { real_target, imaginary_target: target }, );
); } else {
} self.cfg.goto(from_block, source_info, real_target)
_ => self.cfg.goto(from_block, source_info, real_target),
} }
} }
} }
@ -71,10 +68,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
/// a MIR pass run after borrow checking. /// a MIR pass run after borrow checking.
pub(super) fn collect_fake_borrows<'tcx>( pub(super) fn collect_fake_borrows<'tcx>(
cx: &mut Builder<'_, 'tcx>, cx: &mut Builder<'_, 'tcx>,
candidates: &[&mut Candidate<'_, 'tcx>], candidates: &[Candidate<'_, 'tcx>],
temp_span: Span, temp_span: Span,
scrutinee_base: PlaceBase, scrutinee_base: PlaceBase,
) -> Vec<(Place<'tcx>, Local, FakeBorrowKind)> { ) -> Vec<(Place<'tcx>, Local, FakeBorrowKind)> {
if candidates.iter().all(|candidate| !candidate.has_guard) {
// Fake borrows are only used when there is a guard.
return Vec::new();
}
let mut collector = let mut collector =
FakeBorrowCollector { cx, scrutinee_base, fake_borrows: FxIndexMap::default() }; FakeBorrowCollector { cx, scrutinee_base, fake_borrows: FxIndexMap::default() };
for candidate in candidates.iter() { for candidate in candidates.iter() {
@ -222,57 +223,6 @@ impl<'a, 'b, 'tcx> FakeBorrowCollector<'a, 'b, 'tcx> {
} }
} }
/// Visit all the bindings of these candidates. Because or-alternatives bind the same variables, we
/// only explore the first one of each or-pattern.
pub(super) fn visit_bindings<'tcx>(
candidates: &[&mut Candidate<'_, 'tcx>],
f: impl FnMut(&Binding<'tcx>),
) {
let mut visitor = BindingsVisitor { f, phantom: PhantomData };
for candidate in candidates.iter() {
visitor.visit_candidate(candidate);
}
}
pub(super) struct BindingsVisitor<'tcx, F> {
f: F,
phantom: PhantomData<&'tcx ()>,
}
impl<'tcx, F> BindingsVisitor<'tcx, F>
where
F: FnMut(&Binding<'tcx>),
{
fn visit_candidate(&mut self, candidate: &Candidate<'_, 'tcx>) {
for binding in &candidate.extra_data.bindings {
(self.f)(binding)
}
for match_pair in &candidate.match_pairs {
self.visit_match_pair(match_pair);
}
}
fn visit_flat_pat(&mut self, flat_pat: &FlatPat<'_, 'tcx>) {
for binding in &flat_pat.extra_data.bindings {
(self.f)(binding)
}
for match_pair in &flat_pat.match_pairs {
self.visit_match_pair(match_pair);
}
}
fn visit_match_pair(&mut self, match_pair: &MatchPairTree<'_, 'tcx>) {
if let TestCase::Or { pats, .. } = &match_pair.test_case {
// All the or-alternatives should bind the same locals, so we only visit the first one.
self.visit_flat_pat(&pats[0])
} else {
for subpair in &match_pair.subpairs {
self.visit_match_pair(subpair);
}
}
}
}
#[must_use] #[must_use]
pub(crate) fn ref_pat_borrow_kind(ref_mutability: Mutability) -> BorrowKind { pub(crate) fn ref_pat_borrow_kind(ref_mutability: Mutability) -> BorrowKind {
match ref_mutability { match ref_mutability {

View file

@ -37,11 +37,11 @@ fn full_tested_match() -> () {
} }
bb2: { bb2: {
falseEdge -> [real: bb7, imaginary: bb3]; falseEdge -> [real: bb8, imaginary: bb3];
} }
bb3: { bb3: {
falseEdge -> [real: bb12, imaginary: bb5]; falseEdge -> [real: bb7, imaginary: bb5];
} }
bb4: { bb4: {
@ -50,7 +50,7 @@ fn full_tested_match() -> () {
bb5: { bb5: {
_1 = (const 3_i32, const 3_i32); _1 = (const 3_i32, const 3_i32);
goto -> bb13; goto -> bb14;
} }
bb6: { bb6: {
@ -58,18 +58,33 @@ fn full_tested_match() -> () {
} }
bb7: { bb7: {
StorageLive(_9);
_9 = ((_2 as Some).0: i32);
StorageLive(_10);
_10 = _9;
_1 = (const 2_i32, move _10);
StorageDead(_10);
StorageDead(_9);
goto -> bb14;
}
bb8: {
StorageLive(_6); StorageLive(_6);
_6 = &((_2 as Some).0: i32); _6 = &((_2 as Some).0: i32);
_3 = &fake shallow _2; _3 = &fake shallow _2;
StorageLive(_7); StorageLive(_7);
_7 = guard() -> [return: bb8, unwind: bb15]; _7 = guard() -> [return: bb10, unwind: bb16];
}
bb8: {
switchInt(move _7) -> [0: bb10, otherwise: bb9];
} }
bb9: { bb9: {
goto -> bb3;
}
bb10: {
switchInt(move _7) -> [0: bb12, otherwise: bb11];
}
bb11: {
StorageDead(_7); StorageDead(_7);
FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _3);
FakeRead(ForGuardBinding, _6); FakeRead(ForGuardBinding, _6);
@ -81,31 +96,20 @@ fn full_tested_match() -> () {
StorageDead(_8); StorageDead(_8);
StorageDead(_5); StorageDead(_5);
StorageDead(_6); StorageDead(_6);
goto -> bb13; goto -> bb14;
}
bb10: {
goto -> bb11;
}
bb11: {
StorageDead(_7);
StorageDead(_6);
goto -> bb3;
} }
bb12: { bb12: {
StorageLive(_9);
_9 = ((_2 as Some).0: i32);
StorageLive(_10);
_10 = _9;
_1 = (const 2_i32, move _10);
StorageDead(_10);
StorageDead(_9);
goto -> bb13; goto -> bb13;
} }
bb13: { bb13: {
StorageDead(_7);
StorageDead(_6);
goto -> bb9;
}
bb14: {
PlaceMention(_1); PlaceMention(_1);
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);
@ -113,12 +117,12 @@ fn full_tested_match() -> () {
return; return;
} }
bb14: { bb15: {
FakeRead(ForMatchedPlace(None), _1); FakeRead(ForMatchedPlace(None), _1);
unreachable; unreachable;
} }
bb15 (cleanup): { bb16 (cleanup): {
resume; resume;
} }
} }

View file

@ -37,7 +37,7 @@ fn full_tested_match2() -> () {
} }
bb2: { bb2: {
falseEdge -> [real: bb7, imaginary: bb5]; falseEdge -> [real: bb8, imaginary: bb5];
} }
bb3: { bb3: {
@ -48,7 +48,7 @@ fn full_tested_match2() -> () {
_1 = (const 2_i32, move _10); _1 = (const 2_i32, move _10);
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
goto -> bb13; goto -> bb14;
} }
bb4: { bb4: {
@ -56,7 +56,7 @@ fn full_tested_match2() -> () {
} }
bb5: { bb5: {
falseEdge -> [real: bb12, imaginary: bb3]; falseEdge -> [real: bb7, imaginary: bb3];
} }
bb6: { bb6: {
@ -64,18 +64,27 @@ fn full_tested_match2() -> () {
} }
bb7: { bb7: {
_1 = (const 3_i32, const 3_i32);
goto -> bb14;
}
bb8: {
StorageLive(_6); StorageLive(_6);
_6 = &((_2 as Some).0: i32); _6 = &((_2 as Some).0: i32);
_3 = &fake shallow _2; _3 = &fake shallow _2;
StorageLive(_7); StorageLive(_7);
_7 = guard() -> [return: bb8, unwind: bb15]; _7 = guard() -> [return: bb10, unwind: bb16];
}
bb8: {
switchInt(move _7) -> [0: bb10, otherwise: bb9];
} }
bb9: { bb9: {
falseEdge -> [real: bb3, imaginary: bb5];
}
bb10: {
switchInt(move _7) -> [0: bb12, otherwise: bb11];
}
bb11: {
StorageDead(_7); StorageDead(_7);
FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _3);
FakeRead(ForGuardBinding, _6); FakeRead(ForGuardBinding, _6);
@ -87,25 +96,20 @@ fn full_tested_match2() -> () {
StorageDead(_8); StorageDead(_8);
StorageDead(_5); StorageDead(_5);
StorageDead(_6); StorageDead(_6);
goto -> bb13; goto -> bb14;
}
bb10: {
goto -> bb11;
}
bb11: {
StorageDead(_7);
StorageDead(_6);
falseEdge -> [real: bb3, imaginary: bb5];
} }
bb12: { bb12: {
_1 = (const 3_i32, const 3_i32);
goto -> bb13; goto -> bb13;
} }
bb13: { bb13: {
StorageDead(_7);
StorageDead(_6);
goto -> bb9;
}
bb14: {
PlaceMention(_1); PlaceMention(_1);
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);
@ -113,12 +117,12 @@ fn full_tested_match2() -> () {
return; return;
} }
bb14: { bb15: {
FakeRead(ForMatchedPlace(None), _1); FakeRead(ForMatchedPlace(None), _1);
unreachable; unreachable;
} }
bb15 (cleanup): { bb16 (cleanup): {
resume; resume;
} }
} }

View file

@ -43,11 +43,11 @@ fn main() -> () {
} }
bb1: { bb1: {
falseEdge -> [real: bb14, imaginary: bb4]; falseEdge -> [real: bb11, imaginary: bb4];
} }
bb2: { bb2: {
falseEdge -> [real: bb9, imaginary: bb1]; falseEdge -> [real: bb12, imaginary: bb1];
} }
bb3: { bb3: {
@ -64,11 +64,11 @@ fn main() -> () {
_14 = _2; _14 = _2;
_1 = const 4_i32; _1 = const 4_i32;
StorageDead(_14); StorageDead(_14);
goto -> bb20; goto -> bb22;
} }
bb6: { bb6: {
falseEdge -> [real: bb15, imaginary: bb5]; falseEdge -> [real: bb9, imaginary: bb5];
} }
bb7: { bb7: {
@ -81,18 +81,44 @@ fn main() -> () {
} }
bb9: { bb9: {
StorageLive(_11);
_11 = &((_2 as Some).0: i32);
_3 = &fake shallow _2;
StorageLive(_12);
StorageLive(_13);
_13 = (*_11);
_12 = guard2(move _13) -> [return: bb18, unwind: bb24];
}
bb10: {
falseEdge -> [real: bb7, imaginary: bb5];
}
bb11: {
StorageLive(_9);
_9 = _2;
_1 = const 2_i32;
StorageDead(_9);
goto -> bb22;
}
bb12: {
StorageLive(_7); StorageLive(_7);
_7 = &((_2 as Some).0: i32); _7 = &((_2 as Some).0: i32);
_3 = &fake shallow _2; _3 = &fake shallow _2;
StorageLive(_8); StorageLive(_8);
_8 = guard() -> [return: bb10, unwind: bb22]; _8 = guard() -> [return: bb14, unwind: bb24];
} }
bb10: { bb13: {
switchInt(move _8) -> [0: bb12, otherwise: bb11]; falseEdge -> [real: bb3, imaginary: bb1];
} }
bb11: { bb14: {
switchInt(move _8) -> [0: bb16, otherwise: bb15];
}
bb15: {
StorageDead(_8); StorageDead(_8);
FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _3);
FakeRead(ForGuardBinding, _7); FakeRead(ForGuardBinding, _7);
@ -101,42 +127,24 @@ fn main() -> () {
_1 = const 1_i32; _1 = const 1_i32;
StorageDead(_6); StorageDead(_6);
StorageDead(_7); StorageDead(_7);
goto -> bb20; goto -> bb22;
}
bb12: {
goto -> bb13;
}
bb13: {
StorageDead(_8);
StorageDead(_7);
falseEdge -> [real: bb3, imaginary: bb1];
}
bb14: {
StorageLive(_9);
_9 = _2;
_1 = const 2_i32;
StorageDead(_9);
goto -> bb20;
}
bb15: {
StorageLive(_11);
_11 = &((_2 as Some).0: i32);
_3 = &fake shallow _2;
StorageLive(_12);
StorageLive(_13);
_13 = (*_11);
_12 = guard2(move _13) -> [return: bb16, unwind: bb22];
} }
bb16: { bb16: {
switchInt(move _12) -> [0: bb18, otherwise: bb17]; goto -> bb17;
} }
bb17: { bb17: {
StorageDead(_8);
StorageDead(_7);
goto -> bb13;
}
bb18: {
switchInt(move _12) -> [0: bb20, otherwise: bb19];
}
bb19: {
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _3);
@ -146,21 +154,21 @@ fn main() -> () {
_1 = const 3_i32; _1 = const 3_i32;
StorageDead(_10); StorageDead(_10);
StorageDead(_11); StorageDead(_11);
goto -> bb20; goto -> bb22;
}
bb18: {
goto -> bb19;
}
bb19: {
StorageDead(_13);
StorageDead(_12);
StorageDead(_11);
falseEdge -> [real: bb7, imaginary: bb5];
} }
bb20: { bb20: {
goto -> bb21;
}
bb21: {
StorageDead(_13);
StorageDead(_12);
StorageDead(_11);
goto -> bb10;
}
bb22: {
PlaceMention(_1); PlaceMention(_1);
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);
@ -168,12 +176,12 @@ fn main() -> () {
return; return;
} }
bb21: { bb23: {
FakeRead(ForMatchedPlace(None), _1); FakeRead(ForMatchedPlace(None), _1);
unreachable; unreachable;
} }
bb22 (cleanup): { bb24 (cleanup): {
resume; resume;
} }
} }

View file

@ -31,7 +31,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
} }
bb2: { bb2: {
falseEdge -> [real: bb12, imaginary: bb5]; falseEdge -> [real: bb15, imaginary: bb5];
} }
bb3: { bb3: {
@ -39,7 +39,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
} }
bb4: { bb4: {
falseEdge -> [real: bb16, imaginary: bb1]; falseEdge -> [real: bb13, imaginary: bb1];
} }
bb5: { bb5: {
@ -51,7 +51,7 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
} }
bb7: { bb7: {
falseEdge -> [real: bb15, imaginary: bb3]; falseEdge -> [real: bb14, imaginary: bb3];
} }
bb8: { bb8: {
@ -68,18 +68,33 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
} }
bb11: { bb11: {
falseEdge -> [real: bb17, imaginary: bb10]; falseEdge -> [real: bb12, imaginary: bb10];
} }
bb12: { bb12: {
_0 = const 4_u32;
goto -> bb18;
}
bb13: {
_0 = const 3_u32;
goto -> bb18;
}
bb14: {
_0 = const 2_u32;
goto -> bb18;
}
bb15: {
_6 = &fake shallow (_3.0: &str); _6 = &fake shallow (_3.0: &str);
_7 = &fake shallow (_3.1: bool); _7 = &fake shallow (_3.1: bool);
StorageLive(_10); StorageLive(_10);
_10 = const true; _10 = const true;
switchInt(move _10) -> [0: bb14, otherwise: bb13]; switchInt(move _10) -> [0: bb17, otherwise: bb16];
} }
bb13: { bb16: {
StorageDead(_10); StorageDead(_10);
FakeRead(ForMatchGuard, _6); FakeRead(ForMatchGuard, _6);
FakeRead(ForMatchGuard, _7); FakeRead(ForMatchGuard, _7);
@ -87,26 +102,11 @@ fn constant_eq(_1: &str, _2: bool) -> u32 {
goto -> bb18; goto -> bb18;
} }
bb14: { bb17: {
StorageDead(_10); StorageDead(_10);
falseEdge -> [real: bb3, imaginary: bb5]; falseEdge -> [real: bb3, imaginary: bb5];
} }
bb15: {
_0 = const 2_u32;
goto -> bb18;
}
bb16: {
_0 = const 3_u32;
goto -> bb18;
}
bb17: {
_0 = const 4_u32;
goto -> bb18;
}
bb18: { bb18: {
StorageDead(_3); StorageDead(_3);
return; return;

View file

@ -23,7 +23,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 {
} }
bb2: { bb2: {
falseEdge -> [real: bb9, imaginary: bb3]; falseEdge -> [real: bb11, imaginary: bb3];
} }
bb3: { bb3: {
@ -32,7 +32,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 {
} }
bb4: { bb4: {
falseEdge -> [real: bb12, imaginary: bb5]; falseEdge -> [real: bb10, imaginary: bb5];
} }
bb5: { bb5: {
@ -40,7 +40,7 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 {
} }
bb6: { bb6: {
falseEdge -> [real: bb13, imaginary: bb1]; falseEdge -> [real: bb9, imaginary: bb1];
} }
bb7: { bb7: {
@ -54,34 +54,34 @@ fn disjoint_ranges(_1: i32, _2: bool) -> u32 {
} }
bb9: { bb9: {
_3 = &fake shallow _1; _0 = const 2_u32;
StorageLive(_8); goto -> bb14;
_8 = _2;
switchInt(move _8) -> [0: bb11, otherwise: bb10];
} }
bb10: { bb10: {
_0 = const 1_u32;
goto -> bb14;
}
bb11: {
_3 = &fake shallow _1;
StorageLive(_8);
_8 = _2;
switchInt(move _8) -> [0: bb13, otherwise: bb12];
}
bb12: {
StorageDead(_8); StorageDead(_8);
FakeRead(ForMatchGuard, _3); FakeRead(ForMatchGuard, _3);
_0 = const 0_u32; _0 = const 0_u32;
goto -> bb14; goto -> bb14;
} }
bb11: { bb13: {
StorageDead(_8); StorageDead(_8);
falseEdge -> [real: bb1, imaginary: bb3]; falseEdge -> [real: bb1, imaginary: bb3];
} }
bb12: {
_0 = const 1_u32;
goto -> bb14;
}
bb13: {
_0 = const 2_u32;
goto -> bb14;
}
bb14: { bb14: {
return; return;
} }

View file

@ -55,17 +55,17 @@
bb2: { bb2: {
+ Coverage::CounterIncrement(3); + Coverage::CounterIncrement(3);
falseEdge -> [real: bb6, imaginary: bb3]; falseEdge -> [real: bb8, imaginary: bb3];
} }
bb3: { bb3: {
+ Coverage::CounterIncrement(2); + Coverage::CounterIncrement(2);
falseEdge -> [real: bb8, imaginary: bb4]; falseEdge -> [real: bb7, imaginary: bb4];
} }
bb4: { bb4: {
+ Coverage::CounterIncrement(1); + Coverage::CounterIncrement(1);
falseEdge -> [real: bb10, imaginary: bb5]; falseEdge -> [real: bb6, imaginary: bb5];
} }
bb5: { bb5: {
@ -78,34 +78,6 @@
} }
bb6: { bb6: {
StorageLive(_3);
_3 = ((_1 as D).0: u32);
StorageLive(_4);
_4 = _3;
_0 = consume(move _4) -> [return: bb7, unwind: bb14];
}
bb7: {
StorageDead(_4);
StorageDead(_3);
goto -> bb13;
}
bb8: {
StorageLive(_5);
_5 = ((_1 as C).0: u32);
StorageLive(_6);
_6 = _5;
_0 = consume(move _6) -> [return: bb9, unwind: bb14];
}
bb9: {
StorageDead(_6);
StorageDead(_5);
goto -> bb13;
}
bb10: {
StorageLive(_7); StorageLive(_7);
_7 = ((_1 as B).0: u32); _7 = ((_1 as B).0: u32);
StorageLive(_8); StorageLive(_8);
@ -113,6 +85,34 @@
_0 = consume(move _8) -> [return: bb11, unwind: bb14]; _0 = consume(move _8) -> [return: bb11, unwind: bb14];
} }
bb7: {
StorageLive(_5);
_5 = ((_1 as C).0: u32);
StorageLive(_6);
_6 = _5;
_0 = consume(move _6) -> [return: bb10, unwind: bb14];
}
bb8: {
StorageLive(_3);
_3 = ((_1 as D).0: u32);
StorageLive(_4);
_4 = _3;
_0 = consume(move _4) -> [return: bb9, unwind: bb14];
}
bb9: {
StorageDead(_4);
StorageDead(_3);
goto -> bb13;
}
bb10: {
StorageDead(_6);
StorageDead(_5);
goto -> bb13;
}
bb11: { bb11: {
StorageDead(_8); StorageDead(_8);
StorageDead(_7); StorageDead(_7);

View file

@ -33,7 +33,7 @@
_8 = const 3_usize; _8 = const 3_usize;
_9 = Ge(move _7, move _8); _9 = Ge(move _7, move _8);
- switchInt(move _9) -> [0: bb7, otherwise: bb8]; - switchInt(move _9) -> [0: bb7, otherwise: bb8];
+ switchInt(move _9) -> [0: bb10, otherwise: bb7]; + switchInt(move _9) -> [0: bb11, otherwise: bb7];
} }
bb3: { bb3: {
@ -49,48 +49,48 @@
} }
bb6: { bb6: {
- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; - switchInt((*_2)[3 of 4]) -> [47: bb13, otherwise: bb2];
+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; + switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
} }
bb7: { bb7: {
- _0 = const false; - _0 = const false;
- goto -> bb14; - goto -> bb14;
+ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; + switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb11];
} }
bb8: { bb8: {
- switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7]; - switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7];
+ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; + switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb11];
} }
bb9: { bb9: {
- switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7]; - switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7];
+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; + switchInt((*_2)[2 of 3]) -> [47: bb10, 33: bb10, otherwise: bb11];
} }
bb10: { bb10: {
- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7]; - switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb11, otherwise: bb7];
- } - }
- -
- bb11: { - bb11: {
_0 = const false;
- goto -> bb14;
+ goto -> bb12;
}
- bb12: {
+ bb11: {
_0 = const true; _0 = const true;
- goto -> bb14; - goto -> bb14;
+ goto -> bb12; + goto -> bb12;
} }
- bb13: { - bb12: {
- _0 = const true; - _0 = const true;
- goto -> bb14; - goto -> bb14;
- } - }
- -
- bb13: {
+ bb11: {
_0 = const false;
- goto -> bb14;
+ goto -> bb12;
}
- bb14: { - bb14: {
+ bb12: { + bb12: {
StorageDead(_2); StorageDead(_2);

View file

@ -33,7 +33,7 @@
_8 = const 3_usize; _8 = const 3_usize;
_9 = Ge(move _7, move _8); _9 = Ge(move _7, move _8);
- switchInt(move _9) -> [0: bb7, otherwise: bb8]; - switchInt(move _9) -> [0: bb7, otherwise: bb8];
+ switchInt(move _9) -> [0: bb10, otherwise: bb7]; + switchInt(move _9) -> [0: bb11, otherwise: bb7];
} }
bb3: { bb3: {
@ -49,48 +49,48 @@
} }
bb6: { bb6: {
- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; - switchInt((*_2)[3 of 4]) -> [47: bb13, otherwise: bb2];
+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; + switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2];
} }
bb7: { bb7: {
- _0 = const false; - _0 = const false;
- goto -> bb14; - goto -> bb14;
+ switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; + switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb11];
} }
bb8: { bb8: {
- switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7]; - switchInt((*_2)[0 of 3]) -> [47: bb9, otherwise: bb7];
+ switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; + switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb11];
} }
bb9: { bb9: {
- switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7]; - switchInt((*_2)[1 of 3]) -> [47: bb10, otherwise: bb7];
+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; + switchInt((*_2)[2 of 3]) -> [47: bb10, 33: bb10, otherwise: bb11];
} }
bb10: { bb10: {
- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb7]; - switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb11, otherwise: bb7];
- } - }
- -
- bb11: { - bb11: {
_0 = const false;
- goto -> bb14;
+ goto -> bb12;
}
- bb12: {
+ bb11: {
_0 = const true; _0 = const true;
- goto -> bb14; - goto -> bb14;
+ goto -> bb12; + goto -> bb12;
} }
- bb13: { - bb12: {
- _0 = const true; - _0 = const true;
- goto -> bb14; - goto -> bb14;
- } - }
- -
- bb13: {
+ bb11: {
_0 = const false;
- goto -> bb14;
+ goto -> bb12;
}
- bb14: { - bb14: {
+ bb12: { + bb12: {
StorageDead(_2); StorageDead(_2);

View file

@ -38,15 +38,20 @@
bb2: { bb2: {
_6 = discriminant((_3.1: std::option::Option<u32>)); _6 = discriminant((_3.1: std::option::Option<u32>));
switchInt(move _6) -> [1: bb4, 0: bb1, otherwise: bb7]; switchInt(move _6) -> [1: bb5, 0: bb1, otherwise: bb7];
} }
bb3: { bb3: {
_7 = discriminant((_3.1: std::option::Option<u32>)); _7 = discriminant((_3.1: std::option::Option<u32>));
switchInt(move _7) -> [0: bb5, 1: bb1, otherwise: bb7]; switchInt(move _7) -> [0: bb4, 1: bb1, otherwise: bb7];
} }
bb4: { bb4: {
_0 = const 2_u32;
goto -> bb6;
}
bb5: {
StorageLive(_9); StorageLive(_9);
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
StorageLive(_10); StorageLive(_10);
@ -57,11 +62,6 @@
goto -> bb6; goto -> bb6;
} }
bb5: {
_0 = const 2_u32;
goto -> bb6;
}
bb6: { bb6: {
StorageDead(_3); StorageDead(_3);
return; return;

View file

@ -49,7 +49,7 @@
bb2: { bb2: {
- _6 = discriminant((_3.1: Option2<bool>)); - _6 = discriminant((_3.1: Option2<bool>));
- switchInt(move _6) -> [0: bb5, otherwise: bb1]; - switchInt(move _6) -> [0: bb7, otherwise: bb1];
- } - }
- -
- bb3: { - bb3: {
@ -59,17 +59,11 @@
- -
- bb4: { - bb4: {
- _8 = discriminant((_3.1: Option2<bool>)); - _8 = discriminant((_3.1: Option2<bool>));
- switchInt(move _8) -> [2: bb7, otherwise: bb1]; - switchInt(move _8) -> [2: bb5, otherwise: bb1];
- } - }
- -
- bb5: { - bb5: {
StorageLive(_10); _0 = const 3_u32;
_10 = (((_3.0: Option2<u32>) as Some).0: u32);
StorageLive(_11);
_11 = (((_3.1: Option2<bool>) as Some).0: bool);
_0 = const 0_u32;
StorageDead(_11);
StorageDead(_10);
- goto -> bb8; - goto -> bb8;
+ goto -> bb5; + goto -> bb5;
} }
@ -83,7 +77,13 @@
- bb7: { - bb7: {
+ bb4: { + bb4: {
_0 = const 3_u32; StorageLive(_10);
_10 = (((_3.0: Option2<u32>) as Some).0: u32);
StorageLive(_11);
_11 = (((_3.1: Option2<bool>) as Some).0: bool);
_0 = const 0_u32;
StorageDead(_11);
StorageDead(_10);
- goto -> bb8; - goto -> bb8;
+ goto -> bb5; + goto -> bb5;
} }
@ -101,7 +101,7 @@
+ +
+ bb7: { + bb7: {
+ StorageDead(_13); + StorageDead(_13);
+ switchInt(_9) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb6]; + switchInt(_9) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb6];
} }
} }

View file

@ -49,7 +49,7 @@
bb2: { bb2: {
- _6 = discriminant((_3.1: Option2<u32>)); - _6 = discriminant((_3.1: Option2<u32>));
- switchInt(move _6) -> [0: bb5, otherwise: bb1]; - switchInt(move _6) -> [0: bb7, otherwise: bb1];
- } - }
- -
- bb3: { - bb3: {
@ -59,17 +59,11 @@
- -
- bb4: { - bb4: {
- _8 = discriminant((_3.1: Option2<u32>)); - _8 = discriminant((_3.1: Option2<u32>));
- switchInt(move _8) -> [2: bb7, otherwise: bb1]; - switchInt(move _8) -> [2: bb5, otherwise: bb1];
- } - }
- -
- bb5: { - bb5: {
StorageLive(_10); _0 = const 3_u32;
_10 = (((_3.0: Option2<u32>) as Some).0: u32);
StorageLive(_11);
_11 = (((_3.1: Option2<u32>) as Some).0: u32);
_0 = const 0_u32;
StorageDead(_11);
StorageDead(_10);
- goto -> bb8; - goto -> bb8;
+ goto -> bb5; + goto -> bb5;
} }
@ -83,7 +77,13 @@
- bb7: { - bb7: {
+ bb4: { + bb4: {
_0 = const 3_u32; StorageLive(_10);
_10 = (((_3.0: Option2<u32>) as Some).0: u32);
StorageLive(_11);
_11 = (((_3.1: Option2<u32>) as Some).0: u32);
_0 = const 0_u32;
StorageDead(_11);
StorageDead(_10);
- goto -> bb8; - goto -> bb8;
+ goto -> bb5; + goto -> bb5;
} }
@ -101,7 +101,7 @@
+ +
+ bb7: { + bb7: {
+ StorageDead(_13); + StorageDead(_13);
+ switchInt(_9) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb6]; + switchInt(_9) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb6];
} }
} }

View file

@ -52,7 +52,7 @@
bb3: { bb3: {
_8 = discriminant((_4.2: std::option::Option<u32>)); _8 = discriminant((_4.2: std::option::Option<u32>));
switchInt(move _8) -> [1: bb6, 0: bb1, otherwise: bb9]; switchInt(move _8) -> [1: bb7, 0: bb1, otherwise: bb9];
} }
bb4: { bb4: {
@ -62,10 +62,15 @@
bb5: { bb5: {
_10 = discriminant((_4.2: std::option::Option<u32>)); _10 = discriminant((_4.2: std::option::Option<u32>));
switchInt(move _10) -> [0: bb7, 1: bb1, otherwise: bb9]; switchInt(move _10) -> [0: bb6, 1: bb1, otherwise: bb9];
} }
bb6: { bb6: {
_0 = const 2_u32;
goto -> bb8;
}
bb7: {
StorageLive(_13); StorageLive(_13);
_13 = (((_4.0: std::option::Option<u32>) as Some).0: u32); _13 = (((_4.0: std::option::Option<u32>) as Some).0: u32);
StorageLive(_14); StorageLive(_14);
@ -79,11 +84,6 @@
goto -> bb8; goto -> bb8;
} }
bb7: {
_0 = const 2_u32;
goto -> bb8;
}
bb8: { bb8: {
StorageDead(_4); StorageDead(_4);
return; return;

View file

@ -64,8 +64,8 @@
- -
- bb3: { - bb3: {
_8 = discriminant((_4.2: Option2<u32>)); _8 = discriminant((_4.2: Option2<u32>));
- switchInt(move _8) -> [0: bb8, otherwise: bb1]; - switchInt(move _8) -> [0: bb10, otherwise: bb1];
+ switchInt(move _8) -> [0: bb5, otherwise: bb1]; + switchInt(move _8) -> [0: bb7, otherwise: bb1];
} }
- bb4: { - bb4: {
@ -88,22 +88,13 @@
- bb7: { - bb7: {
+ bb4: { + bb4: {
_12 = discriminant((_4.2: Option2<u32>)); _12 = discriminant((_4.2: Option2<u32>));
- switchInt(move _12) -> [2: bb10, otherwise: bb1]; - switchInt(move _12) -> [2: bb8, otherwise: bb1];
+ switchInt(move _12) -> [2: bb7, otherwise: bb1]; + switchInt(move _12) -> [2: bb5, otherwise: bb1];
} }
- bb8: { - bb8: {
+ bb5: { + bb5: {
StorageLive(_15); _0 = const 3_u32;
_15 = (((_4.0: Option2<u32>) as Some).0: u32);
StorageLive(_16);
_16 = (((_4.1: Option2<u32>) as Some).0: u32);
StorageLive(_17);
_17 = (((_4.2: Option2<u32>) as Some).0: u32);
_0 = const 0_u32;
StorageDead(_17);
StorageDead(_16);
StorageDead(_15);
- goto -> bb11; - goto -> bb11;
+ goto -> bb8; + goto -> bb8;
} }
@ -117,7 +108,16 @@
- bb10: { - bb10: {
+ bb7: { + bb7: {
_0 = const 3_u32; StorageLive(_15);
_15 = (((_4.0: Option2<u32>) as Some).0: u32);
StorageLive(_16);
_16 = (((_4.1: Option2<u32>) as Some).0: u32);
StorageLive(_17);
_17 = (((_4.2: Option2<u32>) as Some).0: u32);
_0 = const 0_u32;
StorageDead(_17);
StorageDead(_16);
StorageDead(_15);
- goto -> bb11; - goto -> bb11;
+ goto -> bb8; + goto -> bb8;
} }

View file

@ -94,78 +94,56 @@
bb2: { bb2: {
_35 = deref_copy (_4.1: &ViewportPercentageLength); _35 = deref_copy (_4.1: &ViewportPercentageLength);
_7 = discriminant((*_35)); _7 = discriminant((*_35));
switchInt(move _7) -> [0: bb6, otherwise: bb1]; switchInt(move _7) -> [0: bb9, otherwise: bb1];
} }
bb3: { bb3: {
_36 = deref_copy (_4.1: &ViewportPercentageLength); _36 = deref_copy (_4.1: &ViewportPercentageLength);
_8 = discriminant((*_36)); _8 = discriminant((*_36));
switchInt(move _8) -> [1: bb7, otherwise: bb1]; switchInt(move _8) -> [1: bb8, otherwise: bb1];
} }
bb4: { bb4: {
_37 = deref_copy (_4.1: &ViewportPercentageLength); _37 = deref_copy (_4.1: &ViewportPercentageLength);
_9 = discriminant((*_37)); _9 = discriminant((*_37));
switchInt(move _9) -> [2: bb8, otherwise: bb1]; switchInt(move _9) -> [2: bb7, otherwise: bb1];
} }
bb5: { bb5: {
_38 = deref_copy (_4.1: &ViewportPercentageLength); _38 = deref_copy (_4.1: &ViewportPercentageLength);
_10 = discriminant((*_38)); _10 = discriminant((*_38));
switchInt(move _10) -> [3: bb9, otherwise: bb1]; switchInt(move _10) -> [3: bb6, otherwise: bb1];
} }
bb6: { bb6: {
StorageLive(_12); StorageLive(_27);
_39 = deref_copy (_4.0: &ViewportPercentageLength); _39 = deref_copy (_4.0: &ViewportPercentageLength);
_12 = (((*_39) as Vw).0: f32); _27 = (((*_39) as Vmax).0: f32);
StorageLive(_13); StorageLive(_28);
_40 = deref_copy (_4.1: &ViewportPercentageLength); _40 = deref_copy (_4.1: &ViewportPercentageLength);
_13 = (((*_40) as Vw).0: f32); _28 = (((*_40) as Vmax).0: f32);
StorageLive(_14); StorageLive(_29);
StorageLive(_15); StorageLive(_30);
_15 = _12; _30 = _27;
StorageLive(_16); StorageLive(_31);
_16 = _13; _31 = _28;
_14 = Add(move _15, move _16); _29 = Add(move _30, move _31);
StorageDead(_16); StorageDead(_31);
StorageDead(_15); StorageDead(_30);
_3 = ViewportPercentageLength::Vw(move _14); _3 = ViewportPercentageLength::Vmax(move _29);
StorageDead(_14); StorageDead(_29);
StorageDead(_13); StorageDead(_28);
StorageDead(_12); StorageDead(_27);
goto -> bb10; goto -> bb10;
} }
bb7: { bb7: {
StorageLive(_17);
_41 = deref_copy (_4.0: &ViewportPercentageLength);
_17 = (((*_41) as Vh).0: f32);
StorageLive(_18);
_42 = deref_copy (_4.1: &ViewportPercentageLength);
_18 = (((*_42) as Vh).0: f32);
StorageLive(_19);
StorageLive(_20);
_20 = _17;
StorageLive(_21);
_21 = _18;
_19 = Add(move _20, move _21);
StorageDead(_21);
StorageDead(_20);
_3 = ViewportPercentageLength::Vh(move _19);
StorageDead(_19);
StorageDead(_18);
StorageDead(_17);
goto -> bb10;
}
bb8: {
StorageLive(_22); StorageLive(_22);
_43 = deref_copy (_4.0: &ViewportPercentageLength); _41 = deref_copy (_4.0: &ViewportPercentageLength);
_22 = (((*_43) as Vmin).0: f32); _22 = (((*_41) as Vmin).0: f32);
StorageLive(_23); StorageLive(_23);
_44 = deref_copy (_4.1: &ViewportPercentageLength); _42 = deref_copy (_4.1: &ViewportPercentageLength);
_23 = (((*_44) as Vmin).0: f32); _23 = (((*_42) as Vmin).0: f32);
StorageLive(_24); StorageLive(_24);
StorageLive(_25); StorageLive(_25);
_25 = _22; _25 = _22;
@ -181,25 +159,47 @@
goto -> bb10; goto -> bb10;
} }
bb8: {
StorageLive(_17);
_43 = deref_copy (_4.0: &ViewportPercentageLength);
_17 = (((*_43) as Vh).0: f32);
StorageLive(_18);
_44 = deref_copy (_4.1: &ViewportPercentageLength);
_18 = (((*_44) as Vh).0: f32);
StorageLive(_19);
StorageLive(_20);
_20 = _17;
StorageLive(_21);
_21 = _18;
_19 = Add(move _20, move _21);
StorageDead(_21);
StorageDead(_20);
_3 = ViewportPercentageLength::Vh(move _19);
StorageDead(_19);
StorageDead(_18);
StorageDead(_17);
goto -> bb10;
}
bb9: { bb9: {
StorageLive(_27); StorageLive(_12);
_45 = deref_copy (_4.0: &ViewportPercentageLength); _45 = deref_copy (_4.0: &ViewportPercentageLength);
_27 = (((*_45) as Vmax).0: f32); _12 = (((*_45) as Vw).0: f32);
StorageLive(_28); StorageLive(_13);
_46 = deref_copy (_4.1: &ViewportPercentageLength); _46 = deref_copy (_4.1: &ViewportPercentageLength);
_28 = (((*_46) as Vmax).0: f32); _13 = (((*_46) as Vw).0: f32);
StorageLive(_29); StorageLive(_14);
StorageLive(_30); StorageLive(_15);
_30 = _27; _15 = _12;
StorageLive(_31); StorageLive(_16);
_31 = _28; _16 = _13;
_29 = Add(move _30, move _31); _14 = Add(move _15, move _16);
StorageDead(_31); StorageDead(_16);
StorageDead(_30); StorageDead(_15);
_3 = ViewportPercentageLength::Vmax(move _29); _3 = ViewportPercentageLength::Vw(move _14);
StorageDead(_29); StorageDead(_14);
StorageDead(_28); StorageDead(_13);
StorageDead(_27); StorageDead(_12);
goto -> bb10; goto -> bb10;
} }

View file

@ -45,12 +45,12 @@
bb2: { bb2: {
_6 = discriminant((_3.1: std::option::Option<u32>)); _6 = discriminant((_3.1: std::option::Option<u32>));
switchInt(move _6) -> [0: bb6, 1: bb5, otherwise: bb1]; switchInt(move _6) -> [0: bb6, 1: bb7, otherwise: bb1];
} }
bb3: { bb3: {
_7 = discriminant((_3.1: std::option::Option<u32>)); _7 = discriminant((_3.1: std::option::Option<u32>));
switchInt(move _7) -> [0: bb4, 1: bb7, otherwise: bb1]; switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb1];
} }
bb4: { bb4: {
@ -59,13 +59,10 @@
} }
bb5: { bb5: {
StorageLive(_9); StorageLive(_12);
_9 = (((_3.0: std::option::Option<u32>) as Some).0: u32); _12 = (((_3.1: std::option::Option<u32>) as Some).0: u32);
StorageLive(_10); _0 = const 2_u32;
_10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); StorageDead(_12);
_0 = const 0_u32;
StorageDead(_10);
StorageDead(_9);
goto -> bb8; goto -> bb8;
} }
@ -78,10 +75,13 @@
} }
bb7: { bb7: {
StorageLive(_12); StorageLive(_9);
_12 = (((_3.1: std::option::Option<u32>) as Some).0: u32); _9 = (((_3.0: std::option::Option<u32>) as Some).0: u32);
_0 = const 2_u32; StorageLive(_10);
StorageDead(_12); _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32);
_0 = const 0_u32;
StorageDead(_10);
StorageDead(_9);
goto -> bb8; goto -> bb8;
} }

View file

@ -24,7 +24,7 @@
bb1: { bb1: {
_4 = discriminant(_1); _4 = discriminant(_1);
switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; switchInt(move _4) -> [0: bb6, 1: bb5, 2: bb4, 3: bb3, otherwise: bb2];
} }
bb2: { bb2: {
@ -39,11 +39,11 @@
} }
bb4: { bb4: {
StorageLive(_5); StorageLive(_7);
_5 = DFA::B; _7 = DFA::D;
_1 = move _5; _1 = move _7;
_3 = const (); _3 = const ();
StorageDead(_5); StorageDead(_7);
goto -> bb1; goto -> bb1;
} }
@ -57,11 +57,11 @@
} }
bb6: { bb6: {
StorageLive(_7); StorageLive(_5);
_7 = DFA::D; _5 = DFA::B;
_1 = move _7; _1 = move _5;
_3 = const (); _3 = const ();
StorageDead(_7); StorageDead(_5);
goto -> bb1; goto -> bb1;
} }
} }

View file

@ -24,7 +24,7 @@
bb1: { bb1: {
_4 = discriminant(_1); _4 = discriminant(_1);
switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; switchInt(move _4) -> [0: bb6, 1: bb5, 2: bb4, 3: bb3, otherwise: bb2];
} }
bb2: { bb2: {
@ -39,11 +39,11 @@
} }
bb4: { bb4: {
StorageLive(_5); StorageLive(_7);
_5 = DFA::B; _7 = DFA::D;
_1 = move _5; _1 = move _7;
_3 = const (); _3 = const ();
StorageDead(_5); StorageDead(_7);
goto -> bb1; goto -> bb1;
} }
@ -57,11 +57,11 @@
} }
bb6: { bb6: {
StorageLive(_7); StorageLive(_5);
_7 = DFA::D; _5 = DFA::B;
_1 = move _7; _1 = move _5;
_3 = const (); _3 = const ();
StorageDead(_7); StorageDead(_5);
goto -> bb1; goto -> bb1;
} }
} }

View file

@ -93,19 +93,19 @@ fn dfa() {
// CHECK: {{_.*}} = DFA::A; // CHECK: {{_.*}} = DFA::A;
// CHECK: goto -> bb1; // CHECK: goto -> bb1;
// CHECK: bb1: { // CHECK: bb1: {
// CHECK: switchInt({{.*}}) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; // CHECK: switchInt({{.*}}) -> [0: bb6, 1: bb5, 2: bb4, 3: bb3, otherwise: bb2];
// CHECK: bb2: { // CHECK: bb2: {
// CHECK: unreachable; // CHECK: unreachable;
// CHECK: bb3: { // CHECK: bb3: {
// CHECK: return; // CHECK: return;
// CHECK: bb4: { // CHECK: bb4: {
// CHECK: {{_.*}} = DFA::B; // CHECK: {{_.*}} = DFA::D;
// CHECK: goto -> bb1; // CHECK: goto -> bb1;
// CHECK: bb5: { // CHECK: bb5: {
// CHECK: {{_.*}} = DFA::C; // CHECK: {{_.*}} = DFA::C;
// CHECK: goto -> bb1; // CHECK: goto -> bb1;
// CHECK: bb6: { // CHECK: bb6: {
// CHECK: {{_.*}} = DFA::D; // CHECK: {{_.*}} = DFA::B;
// CHECK: goto -> bb1; // CHECK: goto -> bb1;
let mut state = DFA::A; let mut state = DFA::A;
loop { loop {

View file

@ -33,17 +33,17 @@
bb0: { bb0: {
PlaceMention(_2); PlaceMention(_2);
- switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1]; - switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1];
+ switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; + switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1];
} }
bb1: { bb1: {
- switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3]; - switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3];
+ switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; + switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2];
} }
bb2: { bb2: {
- falseEdge -> [real: bb8, imaginary: bb1]; - falseEdge -> [real: bb9, imaginary: bb1];
+ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; + switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb4];
} }
bb3: { bb3: {
@ -51,11 +51,11 @@
- } - }
- -
- bb4: { - bb4: {
- falseEdge -> [real: bb13, imaginary: bb3]; - falseEdge -> [real: bb8, imaginary: bb3];
- } - }
- -
- bb5: { - bb5: {
- falseEdge -> [real: bb20, imaginary: bb6]; - falseEdge -> [real: bb7, imaginary: bb6];
- } - }
- -
- bb6: { - bb6: {
@ -63,19 +63,37 @@
_15 = (_2.1: bool); _15 = (_2.1: bool);
StorageLive(_16); StorageLive(_16);
_16 = move (_2.2: std::string::String); _16 = move (_2.2: std::string::String);
- goto -> bb19; - goto -> bb20;
+ goto -> bb16; + goto -> bb17;
} }
- bb7: { - bb7: {
+ bb4: { + bb4: {
_0 = const 1_i32; StorageLive(_15);
- drop(_7) -> [return: bb18, unwind: bb25]; _15 = (_2.1: bool);
+ drop(_7) -> [return: bb15, unwind: bb22]; StorageLive(_16);
_16 = move (_2.2: std::string::String);
- goto -> bb20;
+ goto -> bb17;
} }
- bb8: { - bb8: {
+ bb5: { + bb5: {
StorageLive(_6);
_6 = &(_2.0: bool);
StorageLive(_8);
_8 = &(_2.2: std::string::String);
- _3 = &fake shallow (_2.0: bool);
- _4 = &fake shallow (_2.1: bool);
StorageLive(_12);
StorageLive(_13);
_13 = _1;
- switchInt(move _13) -> [0: bb16, otherwise: bb15];
+ switchInt(move _13) -> [0: bb13, otherwise: bb12];
}
- bb9: {
+ bb6: {
StorageLive(_6); StorageLive(_6);
_6 = &(_2.1: bool); _6 = &(_2.1: bool);
StorageLive(_8); StorageLive(_8);
@ -85,12 +103,19 @@
StorageLive(_9); StorageLive(_9);
StorageLive(_10); StorageLive(_10);
_10 = _1; _10 = _1;
- switchInt(move _10) -> [0: bb10, otherwise: bb9]; - switchInt(move _10) -> [0: bb12, otherwise: bb11];
+ switchInt(move _10) -> [0: bb7, otherwise: bb6]; + switchInt(move _10) -> [0: bb9, otherwise: bb8];
} }
- bb9: { - bb10: {
+ bb6: { + bb7: {
_0 = const 1_i32;
- drop(_7) -> [return: bb19, unwind: bb25];
+ drop(_7) -> [return: bb16, unwind: bb22];
}
- bb11: {
+ bb8: {
_0 = const 3_i32; _0 = const 3_i32;
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
@ -98,15 +123,15 @@
+ goto -> bb20; + goto -> bb20;
} }
- bb10: { - bb12: {
+ bb7: { + bb9: {
_9 = (*_6); _9 = (*_6);
- switchInt(move _9) -> [0: bb12, otherwise: bb11]; - switchInt(move _9) -> [0: bb14, otherwise: bb13];
+ switchInt(move _9) -> [0: bb9, otherwise: bb8]; + switchInt(move _9) -> [0: bb11, otherwise: bb10];
} }
- bb11: { - bb13: {
+ bb8: { + bb10: {
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
- FakeRead(ForMatchGuard, _3); - FakeRead(ForMatchGuard, _3);
@ -117,12 +142,12 @@
_5 = (_2.1: bool); _5 = (_2.1: bool);
StorageLive(_7); StorageLive(_7);
_7 = move (_2.2: std::string::String); _7 = move (_2.2: std::string::String);
- goto -> bb7; - goto -> bb10;
+ goto -> bb4; + goto -> bb7;
} }
- bb12: { - bb14: {
+ bb9: { + bb11: {
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
StorageDead(_8); StorageDead(_8);
@ -131,23 +156,8 @@
+ goto -> bb1; + goto -> bb1;
} }
- bb13: { - bb15: {
+ bb10: { + bb12: {
StorageLive(_6);
_6 = &(_2.0: bool);
StorageLive(_8);
_8 = &(_2.2: std::string::String);
- _3 = &fake shallow (_2.0: bool);
- _4 = &fake shallow (_2.1: bool);
StorageLive(_12);
StorageLive(_13);
_13 = _1;
- switchInt(move _13) -> [0: bb15, otherwise: bb14];
+ switchInt(move _13) -> [0: bb12, otherwise: bb11];
}
- bb14: {
+ bb11: {
_0 = const 3_i32; _0 = const 3_i32;
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
@ -155,15 +165,15 @@
+ goto -> bb20; + goto -> bb20;
} }
- bb15: {
+ bb12: {
_12 = (*_6);
- switchInt(move _12) -> [0: bb17, otherwise: bb16];
+ switchInt(move _12) -> [0: bb14, otherwise: bb13];
}
- bb16: { - bb16: {
+ bb13: { + bb13: {
_12 = (*_6);
- switchInt(move _12) -> [0: bb18, otherwise: bb17];
+ switchInt(move _12) -> [0: bb15, otherwise: bb14];
}
- bb17: {
+ bb14: {
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
- FakeRead(ForMatchGuard, _3); - FakeRead(ForMatchGuard, _3);
@ -174,12 +184,12 @@
_5 = (_2.0: bool); _5 = (_2.0: bool);
StorageLive(_7); StorageLive(_7);
_7 = move (_2.2: std::string::String); _7 = move (_2.2: std::string::String);
- goto -> bb7; - goto -> bb10;
+ goto -> bb4; + goto -> bb7;
} }
- bb17: { - bb18: {
+ bb14: { + bb15: {
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
StorageDead(_8); StorageDead(_8);
@ -188,8 +198,8 @@
+ goto -> bb2; + goto -> bb2;
} }
- bb18: { - bb19: {
+ bb15: { + bb16: {
StorageDead(_7); StorageDead(_7);
StorageDead(_5); StorageDead(_5);
StorageDead(_8); StorageDead(_8);
@ -198,23 +208,13 @@
+ goto -> bb19; + goto -> bb19;
} }
- bb19: { - bb20: {
+ bb16: { + bb17: {
_0 = const 2_i32; _0 = const 2_i32;
- drop(_16) -> [return: bb21, unwind: bb25]; - drop(_16) -> [return: bb21, unwind: bb25];
+ drop(_16) -> [return: bb18, unwind: bb22]; + drop(_16) -> [return: bb18, unwind: bb22];
} }
- bb20: {
+ bb17: {
StorageLive(_15);
_15 = (_2.1: bool);
StorageLive(_16);
_16 = move (_2.2: std::string::String);
- goto -> bb19;
+ goto -> bb16;
}
- bb21: { - bb21: {
+ bb18: { + bb18: {
StorageDead(_16); StorageDead(_16);

View file

@ -33,17 +33,17 @@
bb0: { bb0: {
PlaceMention(_2); PlaceMention(_2);
- switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1]; - switchInt((_2.0: bool)) -> [0: bb2, otherwise: bb1];
+ switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; + switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1];
} }
bb1: { bb1: {
- switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3]; - switchInt((_2.1: bool)) -> [0: bb4, otherwise: bb3];
+ switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; + switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2];
} }
bb2: { bb2: {
- falseEdge -> [real: bb8, imaginary: bb1]; - falseEdge -> [real: bb9, imaginary: bb1];
+ switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; + switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb4];
} }
bb3: { bb3: {
@ -51,11 +51,11 @@
- } - }
- -
- bb4: { - bb4: {
- falseEdge -> [real: bb13, imaginary: bb3]; - falseEdge -> [real: bb8, imaginary: bb3];
- } - }
- -
- bb5: { - bb5: {
- falseEdge -> [real: bb20, imaginary: bb6]; - falseEdge -> [real: bb7, imaginary: bb6];
- } - }
- -
- bb6: { - bb6: {
@ -63,19 +63,37 @@
_15 = (_2.1: bool); _15 = (_2.1: bool);
StorageLive(_16); StorageLive(_16);
_16 = move (_2.2: std::string::String); _16 = move (_2.2: std::string::String);
- goto -> bb19; - goto -> bb20;
+ goto -> bb16; + goto -> bb17;
} }
- bb7: { - bb7: {
+ bb4: { + bb4: {
_0 = const 1_i32; StorageLive(_15);
- drop(_7) -> [return: bb18, unwind: bb25]; _15 = (_2.1: bool);
+ drop(_7) -> [return: bb15, unwind: bb22]; StorageLive(_16);
_16 = move (_2.2: std::string::String);
- goto -> bb20;
+ goto -> bb17;
} }
- bb8: { - bb8: {
+ bb5: { + bb5: {
StorageLive(_6);
_6 = &(_2.0: bool);
StorageLive(_8);
_8 = &(_2.2: std::string::String);
- _3 = &fake shallow (_2.0: bool);
- _4 = &fake shallow (_2.1: bool);
StorageLive(_12);
StorageLive(_13);
_13 = _1;
- switchInt(move _13) -> [0: bb16, otherwise: bb15];
+ switchInt(move _13) -> [0: bb13, otherwise: bb12];
}
- bb9: {
+ bb6: {
StorageLive(_6); StorageLive(_6);
_6 = &(_2.1: bool); _6 = &(_2.1: bool);
StorageLive(_8); StorageLive(_8);
@ -85,12 +103,19 @@
StorageLive(_9); StorageLive(_9);
StorageLive(_10); StorageLive(_10);
_10 = _1; _10 = _1;
- switchInt(move _10) -> [0: bb10, otherwise: bb9]; - switchInt(move _10) -> [0: bb12, otherwise: bb11];
+ switchInt(move _10) -> [0: bb7, otherwise: bb6]; + switchInt(move _10) -> [0: bb9, otherwise: bb8];
} }
- bb9: { - bb10: {
+ bb6: { + bb7: {
_0 = const 1_i32;
- drop(_7) -> [return: bb19, unwind: bb25];
+ drop(_7) -> [return: bb16, unwind: bb22];
}
- bb11: {
+ bb8: {
_0 = const 3_i32; _0 = const 3_i32;
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
@ -98,15 +123,15 @@
+ goto -> bb20; + goto -> bb20;
} }
- bb10: { - bb12: {
+ bb7: { + bb9: {
_9 = (*_6); _9 = (*_6);
- switchInt(move _9) -> [0: bb12, otherwise: bb11]; - switchInt(move _9) -> [0: bb14, otherwise: bb13];
+ switchInt(move _9) -> [0: bb9, otherwise: bb8]; + switchInt(move _9) -> [0: bb11, otherwise: bb10];
} }
- bb11: { - bb13: {
+ bb8: { + bb10: {
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
- FakeRead(ForMatchGuard, _3); - FakeRead(ForMatchGuard, _3);
@ -117,12 +142,12 @@
_5 = (_2.1: bool); _5 = (_2.1: bool);
StorageLive(_7); StorageLive(_7);
_7 = move (_2.2: std::string::String); _7 = move (_2.2: std::string::String);
- goto -> bb7; - goto -> bb10;
+ goto -> bb4; + goto -> bb7;
} }
- bb12: { - bb14: {
+ bb9: { + bb11: {
StorageDead(_10); StorageDead(_10);
StorageDead(_9); StorageDead(_9);
StorageDead(_8); StorageDead(_8);
@ -131,23 +156,8 @@
+ goto -> bb1; + goto -> bb1;
} }
- bb13: { - bb15: {
+ bb10: { + bb12: {
StorageLive(_6);
_6 = &(_2.0: bool);
StorageLive(_8);
_8 = &(_2.2: std::string::String);
- _3 = &fake shallow (_2.0: bool);
- _4 = &fake shallow (_2.1: bool);
StorageLive(_12);
StorageLive(_13);
_13 = _1;
- switchInt(move _13) -> [0: bb15, otherwise: bb14];
+ switchInt(move _13) -> [0: bb12, otherwise: bb11];
}
- bb14: {
+ bb11: {
_0 = const 3_i32; _0 = const 3_i32;
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
@ -155,15 +165,15 @@
+ goto -> bb20; + goto -> bb20;
} }
- bb15: {
+ bb12: {
_12 = (*_6);
- switchInt(move _12) -> [0: bb17, otherwise: bb16];
+ switchInt(move _12) -> [0: bb14, otherwise: bb13];
}
- bb16: { - bb16: {
+ bb13: { + bb13: {
_12 = (*_6);
- switchInt(move _12) -> [0: bb18, otherwise: bb17];
+ switchInt(move _12) -> [0: bb15, otherwise: bb14];
}
- bb17: {
+ bb14: {
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
- FakeRead(ForMatchGuard, _3); - FakeRead(ForMatchGuard, _3);
@ -174,12 +184,12 @@
_5 = (_2.0: bool); _5 = (_2.0: bool);
StorageLive(_7); StorageLive(_7);
_7 = move (_2.2: std::string::String); _7 = move (_2.2: std::string::String);
- goto -> bb7; - goto -> bb10;
+ goto -> bb4; + goto -> bb7;
} }
- bb17: { - bb18: {
+ bb14: { + bb15: {
StorageDead(_13); StorageDead(_13);
StorageDead(_12); StorageDead(_12);
StorageDead(_8); StorageDead(_8);
@ -188,8 +198,8 @@
+ goto -> bb2; + goto -> bb2;
} }
- bb18: { - bb19: {
+ bb15: { + bb16: {
StorageDead(_7); StorageDead(_7);
StorageDead(_5); StorageDead(_5);
StorageDead(_8); StorageDead(_8);
@ -198,23 +208,13 @@
+ goto -> bb19; + goto -> bb19;
} }
- bb19: { - bb20: {
+ bb16: { + bb17: {
_0 = const 2_i32; _0 = const 2_i32;
- drop(_16) -> [return: bb21, unwind: bb25]; - drop(_16) -> [return: bb21, unwind: bb25];
+ drop(_16) -> [return: bb18, unwind: bb22]; + drop(_16) -> [return: bb18, unwind: bb22];
} }
- bb20: {
+ bb17: {
StorageLive(_15);
_15 = (_2.1: bool);
StorageLive(_16);
_16 = move (_2.2: std::string::String);
- goto -> bb19;
+ goto -> bb16;
}
- bb21: { - bb21: {
+ bb18: { + bb18: {
StorageDead(_16); StorageDead(_16);

View file

@ -8,7 +8,7 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
switchInt(move _2) -> [1: bb3, 2: bb4, 3: bb5, 340282366920938463463374607431768211455: bb2, otherwise: bb1]; switchInt(move _2) -> [1: bb5, 2: bb4, 3: bb3, 340282366920938463463374607431768211455: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -21,7 +21,7 @@
} }
bb3: { bb3: {
_0 = const 1_u128; _0 = const 3_u128;
goto -> bb6; goto -> bb6;
} }
@ -31,7 +31,7 @@
} }
bb5: { bb5: {
_0 = const 3_u128; _0 = const 1_u128;
goto -> bb6; goto -> bb6;
} }

View file

@ -8,7 +8,7 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
switchInt(move _2) -> [65535: bb3, 2: bb4, 65533: bb2, otherwise: bb1]; switchInt(move _2) -> [65535: bb4, 2: bb3, 65533: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -21,12 +21,12 @@
} }
bb3: { bb3: {
_0 = const -1_i8; _0 = const 2_i8;
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = const 2_i8; _0 = const -1_i8;
goto -> bb5; goto -> bb5;
} }

View file

@ -8,7 +8,7 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
switchInt(move _2) -> [255: bb3, 2: bb4, 253: bb2, otherwise: bb1]; switchInt(move _2) -> [255: bb4, 2: bb3, 253: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -21,12 +21,12 @@
} }
bb3: { bb3: {
_0 = const -1_i16; _0 = const 2_i16;
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = const 2_i16; _0 = const -1_i16;
goto -> bb5; goto -> bb5;
} }

View file

@ -8,7 +8,7 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
switchInt(move _2) -> [255: bb3, 2: bb4, 253: bb2, otherwise: bb1]; switchInt(move _2) -> [255: bb4, 2: bb3, 253: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -21,12 +21,12 @@
} }
bb3: { bb3: {
_0 = const -1_i16; _0 = const 2_i16;
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = const 2_i16; _0 = const -1_i16;
goto -> bb5; goto -> bb5;
} }

View file

@ -6,7 +6,7 @@
let mut _0: i16; let mut _0: i16;
bb0: { bb0: {
switchInt(_1) -> [1: bb2, 2: bb3, otherwise: bb1]; switchInt(_1) -> [1: bb3, 2: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -15,12 +15,12 @@
} }
bb2: { bb2: {
_0 = const 1_i16; _0 = const 2_i16;
goto -> bb4; goto -> bb4;
} }
bb3: { bb3: {
_0 = const 2_i16; _0 = const 1_i16;
goto -> bb4; goto -> bb4;
} }

View file

@ -8,7 +8,7 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
switchInt(move _2) -> [1: bb3, 2: bb4, 5: bb2, otherwise: bb1]; switchInt(move _2) -> [1: bb4, 2: bb3, 5: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -21,12 +21,12 @@
} }
bb3: { bb3: {
_0 = const 1_u16; _0 = const 2_u16;
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = const 2_u16; _0 = const 1_u16;
goto -> bb5; goto -> bb5;
} }

View file

@ -39,7 +39,7 @@ fn shortcut_second_or() -> () {
} }
bb5: { bb5: {
falseEdge -> [real: bb10, imaginary: bb6]; falseEdge -> [real: bb12, imaginary: bb6];
} }
bb6: { bb6: {
@ -47,18 +47,19 @@ fn shortcut_second_or() -> () {
} }
bb7: { bb7: {
falseEdge -> [real: bb12, imaginary: bb8]; falseEdge -> [real: bb10, imaginary: bb8];
} }
bb8: { bb8: {
falseEdge -> [real: bb13, imaginary: bb3]; falseEdge -> [real: bb9, imaginary: bb3];
} }
bb9: { bb9: {
_0 = const (); StorageLive(_3);
StorageDead(_4); _3 = (_1.0: (i32, i32));
StorageDead(_3); StorageLive(_4);
goto -> bb14; _4 = (_1.1: i32);
goto -> bb13;
} }
bb10: { bb10: {
@ -66,7 +67,7 @@ fn shortcut_second_or() -> () {
_3 = (_1.0: (i32, i32)); _3 = (_1.0: (i32, i32));
StorageLive(_4); StorageLive(_4);
_4 = (_1.1: i32); _4 = (_1.1: i32);
goto -> bb9; goto -> bb13;
} }
bb11: { bb11: {
@ -74,7 +75,7 @@ fn shortcut_second_or() -> () {
_3 = (_1.0: (i32, i32)); _3 = (_1.0: (i32, i32));
StorageLive(_4); StorageLive(_4);
_4 = (_1.1: i32); _4 = (_1.1: i32);
goto -> bb9; goto -> bb13;
} }
bb12: { bb12: {
@ -82,15 +83,14 @@ fn shortcut_second_or() -> () {
_3 = (_1.0: (i32, i32)); _3 = (_1.0: (i32, i32));
StorageLive(_4); StorageLive(_4);
_4 = (_1.1: i32); _4 = (_1.1: i32);
goto -> bb9; goto -> bb13;
} }
bb13: { bb13: {
StorageLive(_3); _0 = const ();
_3 = (_1.0: (i32, i32)); StorageDead(_4);
StorageLive(_4); StorageDead(_3);
_4 = (_1.1: i32); goto -> bb14;
goto -> bb9;
} }
bb14: { bb14: {

View file

@ -22,7 +22,7 @@ fn single_switchint() -> () {
} }
bb3: { bb3: {
falseEdge -> [real: bb9, imaginary: bb4]; falseEdge -> [real: bb12, imaginary: bb4];
} }
bb4: { bb4: {
@ -30,11 +30,11 @@ fn single_switchint() -> () {
} }
bb5: { bb5: {
falseEdge -> [real: bb10, imaginary: bb6]; falseEdge -> [real: bb11, imaginary: bb6];
} }
bb6: { bb6: {
falseEdge -> [real: bb11, imaginary: bb1]; falseEdge -> [real: bb10, imaginary: bb1];
} }
bb7: { bb7: {
@ -43,26 +43,26 @@ fn single_switchint() -> () {
} }
bb8: { bb8: {
falseEdge -> [real: bb12, imaginary: bb7]; falseEdge -> [real: bb9, imaginary: bb7];
} }
bb9: { bb9: {
_1 = const 1_i32; _1 = const 4_i32;
goto -> bb13; goto -> bb13;
} }
bb10: { bb10: {
_1 = const 2_i32;
goto -> bb13;
}
bb11: {
_1 = const 3_i32; _1 = const 3_i32;
goto -> bb13; goto -> bb13;
} }
bb11: {
_1 = const 2_i32;
goto -> bb13;
}
bb12: { bb12: {
_1 = const 4_i32; _1 = const 1_i32;
goto -> bb13; goto -> bb13;
} }

View file

@ -8,9 +8,9 @@
bb0: { bb0: {
StorageLive(_1); StorageLive(_1);
- _1 = const <T as MyTrait>::ASSOC_INT; - _1 = const <T as MyTrait>::ASSOC_INT;
- switchInt(_1) -> [7: bb2, 42: bb3, otherwise: bb1]; - switchInt(_1) -> [7: bb3, 42: bb2, otherwise: bb1];
+ nop; + nop;
+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb2, 42: bb3, otherwise: bb1]; + switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -19,12 +19,12 @@
} }
bb2: { bb2: {
_0 = const "hello"; _0 = const "towel";
goto -> bb4; goto -> bb4;
} }
bb3: { bb3: {
_0 = const "towel"; _0 = const "hello";
goto -> bb4; goto -> bb4;
} }

View file

@ -8,9 +8,9 @@
bb0: { bb0: {
StorageLive(_1); StorageLive(_1);
- _1 = const <T as MyTrait>::ASSOC_INT; - _1 = const <T as MyTrait>::ASSOC_INT;
- switchInt(_1) -> [7: bb2, 42: bb3, otherwise: bb1]; - switchInt(_1) -> [7: bb3, 42: bb2, otherwise: bb1];
+ nop; + nop;
+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb2, 42: bb3, otherwise: bb1]; + switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -19,12 +19,12 @@
} }
bb2: { bb2: {
_0 = const "hello"; _0 = const "towel";
goto -> bb4; goto -> bb4;
} }
bb3: { bb3: {
_0 = const "towel"; _0 = const "hello";
goto -> bb4; goto -> bb4;
} }

View file

@ -20,8 +20,8 @@
bb1: { bb1: {
StorageDead(_2); StorageDead(_2);
- switchInt(_1) -> [7: bb3, 42: bb4, otherwise: bb2]; - switchInt(_1) -> [7: bb4, 42: bb3, otherwise: bb2];
+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb4, otherwise: bb2]; + switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb4, 42: bb3, otherwise: bb2];
} }
bb2: { bb2: {
@ -30,12 +30,12 @@
} }
bb3: { bb3: {
_0 = const "hello"; _0 = const "towel";
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = const "towel"; _0 = const "hello";
goto -> bb5; goto -> bb5;
} }

View file

@ -20,8 +20,8 @@
bb1: { bb1: {
StorageDead(_2); StorageDead(_2);
- switchInt(_1) -> [7: bb3, 42: bb4, otherwise: bb2]; - switchInt(_1) -> [7: bb4, 42: bb3, otherwise: bb2];
+ switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb3, 42: bb4, otherwise: bb2]; + switchInt(const <T as MyTrait>::ASSOC_INT) -> [7: bb4, 42: bb3, otherwise: bb2];
} }
bb2: { bb2: {
@ -30,12 +30,12 @@
} }
bb3: { bb3: {
_0 = const "hello"; _0 = const "towel";
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = const "towel"; _0 = const "hello";
goto -> bb5; goto -> bb5;
} }

View file

@ -8,8 +8,8 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
- switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb1]; - switchInt(move _2) -> [1: bb2, 2: bb3, otherwise: bb1];
+ switchInt(move _2) -> [1: bb3, 2: bb2, otherwise: bb5]; + switchInt(move _2) -> [1: bb2, 2: bb3, otherwise: bb5];
} }
bb1: { bb1: {
@ -18,12 +18,12 @@
} }
bb2: { bb2: {
_0 = const 1_u32; _0 = const 2_u32;
goto -> bb4; goto -> bb4;
} }
bb3: { bb3: {
_0 = const 2_u32; _0 = const 1_u32;
goto -> bb4; goto -> bb4;
} }

View file

@ -8,8 +8,8 @@
bb0: { bb0: {
_2 = discriminant(_1); _2 = discriminant(_1);
- switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; - switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _2) -> [0: bb5, 1: bb3, 2: bb1, otherwise: bb5]; + switchInt(move _2) -> [0: bb5, 1: bb2, 2: bb1, otherwise: bb5];
} }
bb1: { bb1: {
@ -18,12 +18,12 @@
} }
bb2: { bb2: {
_0 = const 1_u32; _0 = const 2_u32;
goto -> bb4; goto -> bb4;
} }
bb3: { bb3: {
_0 = const 2_u32; _0 = const 1_u32;
goto -> bb4; goto -> bb4;
} }

View file

@ -30,8 +30,8 @@
StorageLive(_4); StorageLive(_4);
_4 = &(_1.1: Test3); _4 = &(_1.1: Test3);
_5 = discriminant((*_4)); _5 = discriminant((*_4));
- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb2, otherwise: bb1]; - switchInt(move _5) -> [0: bb5, 1: bb4, 2: bb3, 3: bb2, otherwise: bb1];
+ switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb5, 3: bb2, otherwise: bb1]; + switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb3, 3: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -47,7 +47,10 @@
} }
bb3: { bb3: {
_3 = const "A(Empty)"; StorageLive(_7);
_7 = const "C";
_3 = &(*_7);
StorageDead(_7);
goto -> bb6; goto -> bb6;
} }
@ -60,10 +63,7 @@
} }
bb5: { bb5: {
StorageLive(_7); _3 = const "A(Empty)";
_7 = const "C";
_3 = &(*_7);
StorageDead(_7);
goto -> bb6; goto -> bb6;
} }
@ -72,8 +72,8 @@
StorageDead(_3); StorageDead(_3);
StorageLive(_9); StorageLive(_9);
_10 = discriminant((_1.1: Test3)); _10 = discriminant((_1.1: Test3));
- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb1]; - switchInt(move _10) -> [0: bb10, 1: bb9, 2: bb8, 3: bb7, otherwise: bb1];
+ switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb10, 3: bb7, otherwise: bb1]; + switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb8, 3: bb7, otherwise: bb1];
} }
bb7: { bb7: {
@ -85,7 +85,10 @@
} }
bb8: { bb8: {
_9 = const "A(Empty)"; StorageLive(_12);
_12 = const "C";
_9 = &(*_12);
StorageDead(_12);
goto -> bb11; goto -> bb11;
} }
@ -98,10 +101,7 @@
} }
bb10: { bb10: {
StorageLive(_12); _9 = const "A(Empty)";
_12 = const "C";
_9 = &(*_12);
StorageDead(_12);
goto -> bb11; goto -> bb11;
} }

View file

@ -30,8 +30,8 @@
StorageLive(_4); StorageLive(_4);
_4 = &(_1.1: Test3); _4 = &(_1.1: Test3);
_5 = discriminant((*_4)); _5 = discriminant((*_4));
- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb2, otherwise: bb1]; - switchInt(move _5) -> [0: bb5, 1: bb4, 2: bb3, 3: bb2, otherwise: bb1];
+ switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb5, 3: bb2, otherwise: bb1]; + switchInt(move _5) -> [0: bb1, 1: bb1, 2: bb3, 3: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -47,7 +47,10 @@
} }
bb3: { bb3: {
_3 = const "A(Empty)"; StorageLive(_7);
_7 = const "C";
_3 = &(*_7);
StorageDead(_7);
goto -> bb6; goto -> bb6;
} }
@ -60,10 +63,7 @@
} }
bb5: { bb5: {
StorageLive(_7); _3 = const "A(Empty)";
_7 = const "C";
_3 = &(*_7);
StorageDead(_7);
goto -> bb6; goto -> bb6;
} }
@ -72,8 +72,8 @@
StorageDead(_3); StorageDead(_3);
StorageLive(_9); StorageLive(_9);
_10 = discriminant((_1.1: Test3)); _10 = discriminant((_1.1: Test3));
- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb1]; - switchInt(move _10) -> [0: bb10, 1: bb9, 2: bb8, 3: bb7, otherwise: bb1];
+ switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb10, 3: bb7, otherwise: bb1]; + switchInt(move _10) -> [0: bb1, 1: bb1, 2: bb8, 3: bb7, otherwise: bb1];
} }
bb7: { bb7: {
@ -85,7 +85,10 @@
} }
bb8: { bb8: {
_9 = const "A(Empty)"; StorageLive(_12);
_12 = const "C";
_9 = &(*_12);
StorageDead(_12);
goto -> bb11; goto -> bb11;
} }
@ -98,10 +101,7 @@
} }
bb10: { bb10: {
StorageLive(_12); _9 = const "A(Empty)";
_12 = const "C";
_9 = &(*_12);
StorageDead(_12);
goto -> bb11; goto -> bb11;
} }

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test1::C; _2 = Test1::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; - switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; + switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5];
} }
@ -27,11 +27,6 @@
} }
bb2: { bb2: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb3: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(Empty)"; _4 = const "B(Empty)";
_1 = &(*_4); _1 = &(*_4);
@ -39,6 +34,11 @@
goto -> bb4; goto -> bb4;
} }
bb3: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb4: { bb4: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test1::C; _2 = Test1::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; - switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5]; + switchInt(move _3) -> [0: bb5, 1: bb5, 2: bb1, otherwise: bb5];
} }
@ -27,11 +27,6 @@
} }
bb2: { bb2: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb3: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(Empty)"; _4 = const "B(Empty)";
_1 = &(*_4); _1 = &(*_4);
@ -39,6 +34,11 @@
goto -> bb4; goto -> bb4;
} }
bb3: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb4: { bb4: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test3::C; _2 = Test3::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; - switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1]; + switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1];
} }
@ -27,11 +27,6 @@
} }
bb2: { bb2: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb3: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(Empty)"; _4 = const "B(Empty)";
_1 = &(*_4); _1 = &(*_4);
@ -39,6 +34,11 @@
goto -> bb4; goto -> bb4;
} }
bb3: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb4: { bb4: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test3::C; _2 = Test3::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; - switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1]; + switchInt(move _3) -> [0: bb5, 1: bb5, otherwise: bb1];
} }
@ -27,11 +27,6 @@
} }
bb2: { bb2: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb3: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(Empty)"; _4 = const "B(Empty)";
_1 = &(*_4); _1 = &(*_4);
@ -39,6 +34,11 @@
goto -> bb4; goto -> bb4;
} }
bb3: {
_1 = const "A(Empty)";
goto -> bb4;
}
bb4: { bb4: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test4::C; _2 = Test4::C;
_3 = discriminant(_2); _3 = discriminant(_2);
switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -26,11 +26,6 @@
} }
bb2: { bb2: {
_1 = const "A(i32)";
goto -> bb4;
}
bb3: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(i32)"; _4 = const "B(i32)";
_1 = &(*_4); _1 = &(*_4);
@ -38,6 +33,11 @@
goto -> bb4; goto -> bb4;
} }
bb3: {
_1 = const "A(i32)";
goto -> bb4;
}
bb4: { bb4: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test4::C; _2 = Test4::C;
_3 = discriminant(_2); _3 = discriminant(_2);
switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1];
} }
bb1: { bb1: {
@ -26,11 +26,6 @@
} }
bb2: { bb2: {
_1 = const "A(i32)";
goto -> bb4;
}
bb3: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(i32)"; _4 = const "B(i32)";
_1 = &(*_4); _1 = &(*_4);
@ -38,6 +33,11 @@
goto -> bb4; goto -> bb4;
} }
bb3: {
_1 = const "A(i32)";
goto -> bb4;
}
bb4: { bb4: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -15,8 +15,8 @@
StorageLive(_2); StorageLive(_2);
_2 = Test4::C; _2 = Test4::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1]; - switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: bb6]; + switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, 3: bb1, otherwise: bb6];
} }
bb1: { bb1: {
@ -28,7 +28,10 @@
} }
bb2: { bb2: {
_1 = const "A(i32)"; StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }
@ -41,10 +44,7 @@
} }
bb4: { bb4: {
StorageLive(_5); _1 = const "A(i32)";
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }

View file

@ -15,8 +15,8 @@
StorageLive(_2); StorageLive(_2);
_2 = Test4::C; _2 = Test4::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1]; - switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: bb6]; + switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, 3: bb1, otherwise: bb6];
} }
bb1: { bb1: {
@ -28,7 +28,10 @@
} }
bb2: { bb2: {
_1 = const "A(i32)"; StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }
@ -41,10 +44,7 @@
} }
bb4: { bb4: {
StorageLive(_5); _1 = const "A(i32)";
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }

View file

@ -16,8 +16,8 @@
StorageLive(_2); StorageLive(_2);
_2 = Test4::C; _2 = Test4::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, otherwise: bb1]; - switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, otherwise: bb1];
+ switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, 3: bb1, otherwise: bb8]; + switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, 3: bb1, otherwise: bb8];
} }
bb1: { bb1: {
@ -29,23 +29,18 @@
} }
bb2: { bb2: {
switchInt(((_2 as A).0: i32)) -> [1: bb3, 2: bb4, otherwise: bb1]; switchInt(((_2 as A).0: i32)) -> [1: bb6, 2: bb5, otherwise: bb1];
} }
bb3: { bb3: {
_1 = const "A(1)"; StorageLive(_6);
_6 = const "C";
_1 = &(*_6);
StorageDead(_6);
goto -> bb7; goto -> bb7;
} }
bb4: { bb4: {
StorageLive(_4);
_4 = const "A(2)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb7;
}
bb5: {
StorageLive(_5); StorageLive(_5);
_5 = const "B(i32)"; _5 = const "B(i32)";
_1 = &(*_5); _1 = &(*_5);
@ -53,11 +48,16 @@
goto -> bb7; goto -> bb7;
} }
bb5: {
StorageLive(_4);
_4 = const "A(2)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb7;
}
bb6: { bb6: {
StorageLive(_6); _1 = const "A(1)";
_6 = const "C";
_1 = &(*_6);
StorageDead(_6);
goto -> bb7; goto -> bb7;
} }

View file

@ -16,8 +16,8 @@
StorageLive(_2); StorageLive(_2);
_2 = Test4::C; _2 = Test4::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, otherwise: bb1]; - switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, otherwise: bb1];
+ switchInt(move _3) -> [0: bb2, 1: bb5, 2: bb6, 3: bb1, otherwise: bb8]; + switchInt(move _3) -> [0: bb2, 1: bb4, 2: bb3, 3: bb1, otherwise: bb8];
} }
bb1: { bb1: {
@ -29,23 +29,18 @@
} }
bb2: { bb2: {
switchInt(((_2 as A).0: i32)) -> [1: bb3, 2: bb4, otherwise: bb1]; switchInt(((_2 as A).0: i32)) -> [1: bb6, 2: bb5, otherwise: bb1];
} }
bb3: { bb3: {
_1 = const "A(1)"; StorageLive(_6);
_6 = const "C";
_1 = &(*_6);
StorageDead(_6);
goto -> bb7; goto -> bb7;
} }
bb4: { bb4: {
StorageLive(_4);
_4 = const "A(2)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb7;
}
bb5: {
StorageLive(_5); StorageLive(_5);
_5 = const "B(i32)"; _5 = const "B(i32)";
_1 = &(*_5); _1 = &(*_5);
@ -53,11 +48,16 @@
goto -> bb7; goto -> bb7;
} }
bb5: {
StorageLive(_4);
_4 = const "A(2)";
_1 = &(*_4);
StorageDead(_4);
goto -> bb7;
}
bb6: { bb6: {
StorageLive(_6); _1 = const "A(1)";
_6 = const "C";
_1 = &(*_6);
StorageDead(_6);
goto -> bb7; goto -> bb7;
} }

View file

@ -15,8 +15,8 @@
StorageLive(_2); StorageLive(_2);
_2 = Test5::<T>::C; _2 = Test5::<T>::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, otherwise: bb1]; - switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, otherwise: bb1];
+ switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, 3: bb1, otherwise: bb7]; + switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, 3: bb1, otherwise: bb7];
} }
bb1: { bb1: {
@ -28,7 +28,10 @@
} }
bb2: { bb2: {
_1 = const "A(T)"; StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }
@ -41,10 +44,7 @@
} }
bb4: { bb4: {
StorageLive(_5); _1 = const "A(T)";
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }

View file

@ -15,8 +15,8 @@
StorageLive(_2); StorageLive(_2);
_2 = Test5::<T>::C; _2 = Test5::<T>::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, otherwise: bb1]; - switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, otherwise: bb1];
+ switchInt(move _3) -> [255: bb2, 0: bb3, 5: bb4, 3: bb1, otherwise: bb8]; + switchInt(move _3) -> [255: bb4, 0: bb3, 5: bb2, 3: bb1, otherwise: bb8];
} }
bb1: { bb1: {
@ -28,7 +28,10 @@
} }
bb2: { bb2: {
_1 = const "A(T)"; StorageLive(_5);
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }
@ -41,10 +44,7 @@
} }
bb4: { bb4: {
StorageLive(_5); _1 = const "A(T)";
_5 = const "C";
_1 = &(*_5);
StorageDead(_5);
goto -> bb5; goto -> bb5;
} }

View file

@ -120,7 +120,7 @@ fn otherwise_t3() {
fn otherwise_t4_unreachable_default() { fn otherwise_t4_unreachable_default() {
// CHECK-LABEL: fn otherwise_t4_unreachable_default( // CHECK-LABEL: fn otherwise_t4_unreachable_default(
// CHECK: [[discr:_.*]] = discriminant( // CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: [[unreachable:bb.*]]]; // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable:bb.*]]];
// CHECK: [[unreachable]]: { // CHECK: [[unreachable]]: {
// CHECK-NEXT: unreachable; // CHECK-NEXT: unreachable;
match Test4::C { match Test4::C {
@ -135,7 +135,7 @@ fn otherwise_t4_unreachable_default() {
fn otherwise_t4_unreachable_default_2() { fn otherwise_t4_unreachable_default_2() {
// CHECK-LABEL: fn otherwise_t4_unreachable_default_2( // CHECK-LABEL: fn otherwise_t4_unreachable_default_2(
// CHECK: [[discr:_.*]] = discriminant( // CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [0: bb2, 1: bb5, 2: bb6, 3: bb1, otherwise: [[unreachable:bb.*]]]; // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable:bb.*]]];
// CHECK: [[unreachable]]: { // CHECK: [[unreachable]]: {
// CHECK-NEXT: unreachable; // CHECK-NEXT: unreachable;
match Test4::C { match Test4::C {
@ -151,7 +151,7 @@ fn otherwise_t4_unreachable_default_2() {
fn otherwise_t4() { fn otherwise_t4() {
// CHECK-LABEL: fn otherwise_t4( // CHECK-LABEL: fn otherwise_t4(
// CHECK: [[discr:_.*]] = discriminant( // CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [0: bb2, 1: bb3, otherwise: [[unreachable:bb.*]]]; // CHECK: switchInt(move [[discr]]) -> [0: {{bb.*}}, 1: {{bb.*}}, otherwise: [[unreachable:bb.*]]];
// CHECK: [[unreachable]]: { // CHECK: [[unreachable]]: {
// CHECK-NOT: unreachable; // CHECK-NOT: unreachable;
// CHECK: } // CHECK: }
@ -166,7 +166,7 @@ fn otherwise_t4() {
fn otherwise_t5_unreachable_default<T>() { fn otherwise_t5_unreachable_default<T>() {
// CHECK-LABEL: fn otherwise_t5_unreachable_default( // CHECK-LABEL: fn otherwise_t5_unreachable_default(
// CHECK: [[discr:_.*]] = discriminant( // CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [255: bb2, 0: bb3, 5: bb4, 3: bb1, otherwise: [[unreachable:bb.*]]]; // CHECK: switchInt(move [[discr]]) -> [255: {{bb.*}}, 0: {{bb.*}}, 5: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable:bb.*]]];
// CHECK: [[unreachable]]: { // CHECK: [[unreachable]]: {
// CHECK-NEXT: unreachable; // CHECK-NEXT: unreachable;
match Test5::<T>::C { match Test5::<T>::C {
@ -183,7 +183,7 @@ fn byref() {
let plop = Plop { xx: 51, test3: Test3::C }; let plop = Plop { xx: 51, test3: Test3::C };
// CHECK: [[ref_discr:_.*]] = discriminant((* // CHECK: [[ref_discr:_.*]] = discriminant((*
// CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb5, 3: bb2, otherwise: [[unreachable]]]; // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable]]];
match &plop.test3 { match &plop.test3 {
Test3::A(_) => "A(Empty)", Test3::A(_) => "A(Empty)",
Test3::B(_) => "B(Empty)", Test3::B(_) => "B(Empty)",
@ -195,7 +195,7 @@ fn byref() {
// CHECK-NEXT: unreachable; // CHECK-NEXT: unreachable;
// CHECK: [[discr:_.*]] = discriminant( // CHECK: [[discr:_.*]] = discriminant(
// CHECK: switchInt(move [[discr]]) -> [0: [[unreachable]], 1: [[unreachable]], 2: bb10, 3: bb7, otherwise: [[unreachable]]]; // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable]], 1: [[unreachable]], 2: {{bb.*}}, 3: {{bb.*}}, otherwise: [[unreachable]]];
match plop.test3 { match plop.test3 {
Test3::A(_) => "A(Empty)", Test3::A(_) => "A(Empty)",
Test3::B(_) => "B(Empty)", Test3::B(_) => "B(Empty)",

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test1::C; _2 = Test1::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1]; - switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1];
} }
@ -31,11 +31,6 @@
} }
bb3: { bb3: {
_1 = const "A(Empty)";
goto -> bb5;
}
bb4: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(Empty)"; _4 = const "B(Empty)";
_1 = &(*_4); _1 = &(*_4);
@ -43,6 +38,11 @@
goto -> bb5; goto -> bb5;
} }
bb4: {
_1 = const "A(Empty)";
goto -> bb5;
}
bb5: { bb5: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -14,7 +14,7 @@
StorageLive(_2); StorageLive(_2);
_2 = Test1::C; _2 = Test1::C;
_3 = discriminant(_2); _3 = discriminant(_2);
- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1]; - switchInt(move _3) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
+ switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1]; + switchInt(move _3) -> [0: bb1, 1: bb1, 2: bb2, otherwise: bb1];
} }
@ -31,11 +31,6 @@
} }
bb3: { bb3: {
_1 = const "A(Empty)";
goto -> bb5;
}
bb4: {
StorageLive(_4); StorageLive(_4);
_4 = const "B(Empty)"; _4 = const "B(Empty)";
_1 = &(*_4); _1 = &(*_4);
@ -43,6 +38,11 @@
goto -> bb5; goto -> bb5;
} }
bb4: {
_1 = const "A(Empty)";
goto -> bb5;
}
bb5: { bb5: {
StorageDead(_2); StorageDead(_2);
StorageDead(_1); StorageDead(_1);

View file

@ -44,14 +44,14 @@ fn demux(_1: u8) -> u8 {
let mut _0: u8; let mut _0: u8;
debug input => _1; debug input => _1;
bb0: { bb0: {
switchInt(_1) -> [0: bb2, 1: bb3, 2: bb4, otherwise: bb1]; switchInt(_1) -> [0: bb4, 1: bb3, 2: bb2, otherwise: bb1];
} }
bb1: { bb1: {
_0 = 0_u8; _0 = 0_u8;
goto -> bb5; goto -> bb5;
} }
bb2: { bb2: {
_0 = 10_u8; _0 = 8_u8;
goto -> bb5; goto -> bb5;
} }
bb3: { bb3: {
@ -59,7 +59,7 @@ fn demux(_1: u8) -> u8 {
goto -> bb5; goto -> bb5;
} }
bb4: { bb4: {
_0 = 8_u8; _0 = 10_u8;
goto -> bb5; goto -> bb5;
} }
bb5: { bb5: {