Skip to content

Optimize matches #60730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,9 +1196,9 @@ pub enum TerminatorKind<'tcx> {
FalseEdges {
/// The target normal control flow will take
real_target: BasicBlock,
/// The list of blocks control flow could conceptually take, but won't
/// in practice
imaginary_targets: Vec<BasicBlock>,
/// A block control flow could conceptually jump to, but won't in
/// practice
imaginary_target: BasicBlock,
},
/// A terminator for blocks that only take one path in reality, but where we
/// reserve the right to unwind in borrowck, even if it won't happen in practice.
Expand Down Expand Up @@ -1335,8 +1335,8 @@ impl<'tcx> TerminatorKind<'tcx> {
SwitchInt { ref targets, .. } => None.into_iter().chain(&targets[..]),
FalseEdges {
ref real_target,
ref imaginary_targets,
} => Some(real_target).into_iter().chain(&imaginary_targets[..]),
ref imaginary_target,
} => Some(real_target).into_iter().chain(slice::from_ref(imaginary_target)),
}
}

Expand Down Expand Up @@ -1422,10 +1422,10 @@ impl<'tcx> TerminatorKind<'tcx> {
} => None.into_iter().chain(&mut targets[..]),
FalseEdges {
ref mut real_target,
ref mut imaginary_targets,
ref mut imaginary_target,
} => Some(real_target)
.into_iter()
.chain(&mut imaginary_targets[..]),
.chain(slice::from_mut(imaginary_target)),
}
}

Expand Down Expand Up @@ -1722,12 +1722,9 @@ impl<'tcx> TerminatorKind<'tcx> {
Assert { cleanup: None, .. } => vec!["".into()],
Assert { .. } => vec!["success".into(), "unwind".into()],
FalseEdges {
ref imaginary_targets,
..
} => {
let mut l = vec!["real".into()];
l.resize(imaginary_targets.len() + 1, "imaginary".into());
l
vec!["real".into(), "imaginary".into()]
}
FalseUnwind {
unwind: Some(_), ..
Expand Down Expand Up @@ -3356,10 +3353,10 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
Unreachable => Unreachable,
FalseEdges {
real_target,
ref imaginary_targets,
imaginary_target,
} => FalseEdges {
real_target,
imaginary_targets: imaginary_targets.clone(),
imaginary_target,
},
FalseUnwind {
real_target,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx
| TerminatorKind::Unreachable
| TerminatorKind::FalseEdges {
real_target: _,
imaginary_targets: _,
imaginary_target: _,
}
| TerminatorKind::FalseUnwind {
real_target: _,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/borrow_check/nll/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
| TerminatorKind::Unreachable
| TerminatorKind::FalseEdges {
real_target: _,
imaginary_targets: _,
imaginary_target: _,
}
| TerminatorKind::FalseUnwind {
real_target: _,
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_mir/borrow_check/nll/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,12 +1792,10 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
}
TerminatorKind::FalseEdges {
real_target,
ref imaginary_targets,
imaginary_target,
} => {
self.assert_iscleanup(body, block_data, real_target, is_cleanup);
for target in imaginary_targets {
self.assert_iscleanup(body, block_data, *target, is_cleanup);
}
self.assert_iscleanup(body, block_data, imaginary_target, is_cleanup);
}
TerminatorKind::FalseUnwind {
real_target,
Expand Down
Loading