more checks for SwitchInt
This commit is contained in:
parent
e07e42433f
commit
9a4bdbff9e
1 changed files with 7 additions and 3 deletions
|
|
@ -90,11 +90,15 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||
TerminatorKind::Goto { target } => {
|
||||
self.check_bb(terminator.source_info.span, *target);
|
||||
}
|
||||
TerminatorKind::SwitchInt { targets, .. } => {
|
||||
if targets.is_empty() {
|
||||
TerminatorKind::SwitchInt { targets, values, .. } => {
|
||||
if targets.len() != values.len() + 1 {
|
||||
self.fail(
|
||||
terminator.source_info.span,
|
||||
"encountered `SwitchInt` terminator with no target to jump to",
|
||||
format!(
|
||||
"encountered `SwitchInt` terminator with {} values, but {} targets (should be values+1)",
|
||||
values.len(),
|
||||
targets.len(),
|
||||
),
|
||||
);
|
||||
}
|
||||
for target in targets {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue