Return early to avoid ICE

This commit is contained in:
Yuki Okushi 2020-05-30 18:48:54 +09:00
parent fcc0e8f7d4
commit 9fd8e1088f

View File

@ -323,6 +323,11 @@ pub fn implements_trait<'a, 'tcx>(
trait_id: DefId,
ty_params: &[GenericArg<'tcx>],
) -> bool {
// Do not check on infer_types to avoid panic in evaluate_obligation.
if ty.has_infer_types() {
return false;
}
let ty = cx.tcx.erase_regions(&ty);
let ty_params = cx.tcx.mk_substs(ty_params.iter());
cx.tcx.type_implements_trait((trait_id, ty, ty_params, cx.param_env))
}