Skip to content

Commit

Permalink
Avoid ICE during repr(packed) well-formedness check via delay_span_…
Browse files Browse the repository at this point in the history
…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.)
  • Loading branch information
pnkfelix committed Mar 6, 2019
1 parent a9da8fc commit d2482fd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit d2482fd

Please sign in to comment.