mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
MIR validation: check switch_ty
This commit is contained in:
parent
3bfd0c9f07
commit
629722893c
@ -121,7 +121,18 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
||||
TerminatorKind::Goto { target } => {
|
||||
self.check_edge(location, *target, EdgeKind::Normal);
|
||||
}
|
||||
TerminatorKind::SwitchInt { targets, values, .. } => {
|
||||
TerminatorKind::SwitchInt { targets, values, switch_ty, discr } => {
|
||||
let ty = discr.ty(&self.body.local_decls, self.tcx);
|
||||
if ty != *switch_ty {
|
||||
self.fail(
|
||||
location,
|
||||
format!(
|
||||
"encountered `SwitchInt` terminator with type mismatch: {:?} != {:?}",
|
||||
ty,
|
||||
switch_ty,
|
||||
),
|
||||
);
|
||||
}
|
||||
if targets.len() != values.len() + 1 {
|
||||
self.fail(
|
||||
location,
|
||||
|
Loading…
Reference in New Issue
Block a user