1
Fork 0

Rollup merge of #102890 - camsteffen:adt-sized-representability, r=cjgillot

Check representability in adt_sized_constraint

Now that representability is a query, we can use it to preemptively avoid a cycle in `adt_sized_constraint`.

I moved the representability check into `check_mod_type_wf` to avoid a scenario where rustc quits before checking all the types for representability. This also removes the check from rustdoc, which is alright AFAIK.

r? ``@cjgillot``
This commit is contained in:
Dylan DPC 2022-10-12 11:11:26 +05:30 committed by GitHub
commit c8a8e7d116
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 50 additions and 91 deletions

View file

@ -380,7 +380,6 @@ fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let def = tcx.adt_def(def_id);
let span = tcx.def_span(def_id);
def.destructor(tcx); // force the destructor to be evaluated
let _ = tcx.representability(def_id);
if def.repr().simd() {
check_simd(tcx, span, def_id);
@ -394,7 +393,6 @@ fn check_union(tcx: TyCtxt<'_>, def_id: LocalDefId) {
let def = tcx.adt_def(def_id);
let span = tcx.def_span(def_id);
def.destructor(tcx); // force the destructor to be evaluated
let _ = tcx.representability(def_id);
check_transparent(tcx, span, def);
check_union_fields(tcx, span, def_id);
check_packed(tcx, span, def);
@ -1489,7 +1487,6 @@ fn check_enum<'tcx>(tcx: TyCtxt<'tcx>, vs: &'tcx [hir::Variant<'tcx>], def_id: L
detect_discriminant_duplicate(tcx, def.discriminants(tcx).collect(), vs, sp);
let _ = tcx.representability(def_id);
check_transparent(tcx, sp, def);
}

View file

@ -1041,6 +1041,8 @@ fn check_type_defn<'tcx, F>(
) where
F: FnMut(&WfCheckingCtxt<'_, 'tcx>) -> Vec<AdtVariant<'tcx>>,
{
let _ = tcx.representability(item.def_id.def_id);
enter_wf_checking_ctxt(tcx, item.span, item.def_id.def_id, |wfcx| {
let variants = lookup_fields(wfcx);
let packed = tcx.adt_def(item.def_id).repr().packed();