Avoid ICE during repr(packed) well-formedness check via delay_span_bug.

(It is possible that there is a more fundamental invariant being
violated, in terms of the `check_type_defn` code assuming that lifting
to tcx will always succeed. But I am unaware of any test input that
hits this that isn't already type-incorrect in some fashion.)
This commit is contained in:
Felix S. Klock II 2019-03-06 13:49:48 +01:00
parent a9da8fc9c2
commit d2482fd36a

View file

@ -250,11 +250,14 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let needs_drop_copy = || {
packed && {
let ty = variant.fields.last().unwrap().ty;
let ty = fcx.tcx.erase_regions(&ty).lift_to_tcx(fcx_tcx)
fcx.tcx.erase_regions(&ty).lift_to_tcx(fcx_tcx)
.map(|ty| ty.needs_drop(fcx_tcx, fcx_tcx.param_env(def_id)))
.unwrap_or_else(|| {
span_bug!(item.span, "inference variables in {:?}", ty)
});
ty.needs_drop(fcx_tcx, fcx_tcx.param_env(def_id))
fcx_tcx.sess.delay_span_bug(
item.span, &format!("inference variables in {:?}", ty));
// Just treat unresolved type expression as if it needs drop.
true
})
}
};
let all_sized =