Skip to content

Commit 70f3e09

Browse files
committed
Always call check_representability with tcx.ensure_ok()
This was previously not possible because `check_representability` was `anon`.
1 parent dbdbf09 commit 70f3e09

5 files changed

Lines changed: 7 additions & 8 deletions

File tree

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ fn check_type_defn<'tcx>(
998998
item: &hir::Item<'tcx>,
999999
all_sized: bool,
10001000
) -> Result<(), ErrorGuaranteed> {
1001-
let _ = tcx.check_representability(item.owner_id.def_id);
1001+
tcx.ensure_ok().check_representability(item.owner_id.def_id);
10021002
let adt_def = tcx.adt_def(item.owner_id);
10031003

10041004
enter_wf_checking_ctxt(tcx, item.owner_id.def_id, |wfcx| {

compiler/rustc_middle/src/queries.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ rustc_queries! {
585585
desc { "checking if `{}` is representable", tcx.def_path_str(key) }
586586
// We don't want recursive representability calls to be forced with
587587
// incremental compilation because, if a cycle occurs, we need the
588-
// entire cycle to be in memory for diagnostics. This means we can't
589-
// use `ensure_ok()` with this query.
588+
// entire cycle to be in memory for diagnostics.
590589
no_force
591590
}
592591

compiler/rustc_middle/src/ty/inhabitedness/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) fn provide(providers: &mut Providers) {
6161
/// requires calling [`InhabitedPredicate::instantiate`]
6262
fn inhabited_predicate_adt(tcx: TyCtxt<'_>, def_id: DefId) -> InhabitedPredicate<'_> {
6363
if let Some(def_id) = def_id.as_local() {
64-
let _ = tcx.check_representability(def_id);
64+
tcx.ensure_ok().check_representability(def_id);
6565
}
6666

6767
let adt = tcx.adt_def(def_id);

compiler/rustc_ty_utils/src/representability.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn check_representability(tcx: TyCtxt<'_>, def_id: LocalDefId) {
1919
DefKind::Struct | DefKind::Union | DefKind::Enum => {
2020
for variant in tcx.adt_def(def_id).variants() {
2121
for field in variant.fields.iter() {
22-
let _ = tcx.check_representability(field.did.expect_local());
22+
tcx.ensure_ok().check_representability(field.did.expect_local());
2323
}
2424
}
2525
}
@@ -35,7 +35,7 @@ fn check_representability_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) {
3535
// This one must be a query rather than a vanilla `check_representability_adt_ty` call. See
3636
// the comment on `check_representability_adt_ty` below for why.
3737
ty::Adt(..) => {
38-
let _ = tcx.check_representability_adt_ty(ty);
38+
tcx.ensure_ok().check_representability_adt_ty(ty);
3939
}
4040
// FIXME(#11924) allow zero-length arrays?
4141
ty::Array(ty, _) => {
@@ -69,7 +69,7 @@ fn check_representability_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) {
6969
fn check_representability_adt_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) {
7070
let ty::Adt(adt, args) = ty.kind() else { bug!("expected adt") };
7171
if let Some(def_id) = adt.did().as_local() {
72-
let _ = tcx.check_representability(def_id);
72+
tcx.ensure_ok().check_representability(def_id);
7373
}
7474
// At this point, we know that the item of the ADT type is representable;
7575
// but the type parameters may cause a cycle with an upstream type

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn adt_sizedness_constraint<'tcx>(
117117
(def_id, sizedness): (DefId, SizedTraitKind),
118118
) -> Option<ty::EarlyBinder<'tcx, Ty<'tcx>>> {
119119
if let Some(def_id) = def_id.as_local() {
120-
let _ = tcx.check_representability(def_id);
120+
tcx.ensure_ok().check_representability(def_id);
121121
}
122122

123123
let def = tcx.adt_def(def_id);

0 commit comments

Comments
 (0)