Skip to content

Commit d2482fd

Browse files
committed
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.)
1 parent a9da8fc commit d2482fd

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librustc_typeck/check/wfcheck.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,14 @@ fn check_type_defn<'a, 'tcx, F>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
250250
let needs_drop_copy = || {
251251
packed && {
252252
let ty = variant.fields.last().unwrap().ty;
253-
let ty = fcx.tcx.erase_regions(&ty).lift_to_tcx(fcx_tcx)
253+
fcx.tcx.erase_regions(&ty).lift_to_tcx(fcx_tcx)
254+
.map(|ty| ty.needs_drop(fcx_tcx, fcx_tcx.param_env(def_id)))
254255
.unwrap_or_else(|| {
255-
span_bug!(item.span, "inference variables in {:?}", ty)
256-
});
257-
ty.needs_drop(fcx_tcx, fcx_tcx.param_env(def_id))
256+
fcx_tcx.sess.delay_span_bug(
257+
item.span, &format!("inference variables in {:?}", ty));
258+
// Just treat unresolved type expression as if it needs drop.
259+
true
260+
})
258261
}
259262
};
260263
let all_sized =

0 commit comments

Comments
 (0)