mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 18:15:07 +03:00
more checks for SwitchInt
This commit is contained in:
@@ -90,11 +90,15 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, _location: Locatio
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user