Normalize function type during validation

During inlining, the callee body is normalized and has types revealed,
but some of locals corresponding to the arguments might come from the
caller body which is not. As a result the caller body does not pass
validation without additional normalization.
This commit is contained in:
Tomasz Miąsko 2020-11-12 00:00:00 +00:00
parent 9722952f0b
commit d486bfcbff
3 changed files with 16 additions and 8 deletions

View file

@ -357,7 +357,9 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
}
TerminatorKind::Call { func, args, destination, cleanup, .. } => {
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
let func_ty = func.ty(&self.body.local_decls, self.tcx);
let func_ty = self.tcx.normalize_erasing_regions(param_env, func_ty);
match func_ty.kind() {
ty::FnPtr(..) | ty::FnDef(..) => {}
_ => self.fail(