Skip to content

Commit 0e7e1bf

Browse files
author
Lukas Markeffsky
committed
make Representability::Infinite carry ErrorGuaranteed
1 parent 30f74ff commit 0e7e1bf

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

compiler/rustc_middle/src/ty/adt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -601,5 +601,5 @@ impl<'tcx> AdtDef<'tcx> {
601601
#[derive(HashStable)]
602602
pub enum Representability {
603603
Representable,
604-
Infinite,
604+
Infinite(ErrorGuaranteed),
605605
}

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

+1-1
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-
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
64+
if matches!(tcx.representability(def_id), ty::Representability::Infinite(_)) {
6565
return InhabitedPredicate::True;
6666
}
6767
}

compiler/rustc_middle/src/values.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
106106
representable_ids.insert(def_id);
107107
}
108108
}
109-
recursive_type_error(tcx, item_and_field_ids, &representable_ids);
110-
Representability::Infinite
109+
let guar = recursive_type_error(tcx, item_and_field_ids, &representable_ids);
110+
Representability::Infinite(guar)
111111
}
112112
}
113113

@@ -268,7 +268,7 @@ pub fn recursive_type_error(
268268
tcx: TyCtxt<'_>,
269269
mut item_and_field_ids: Vec<(LocalDefId, LocalDefId)>,
270270
representable_ids: &FxHashSet<LocalDefId>,
271-
) {
271+
) -> ErrorGuaranteed {
272272
const ITEM_LIMIT: usize = 5;
273273

274274
// Rotate the cycle so that the item with the lowest span is first
@@ -344,7 +344,7 @@ pub fn recursive_type_error(
344344
suggestion,
345345
Applicability::HasPlaceholders,
346346
)
347-
.emit();
347+
.emit()
348348
}
349349

350350
fn find_item_ty_spans(

compiler/rustc_ty_utils/src/representability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub(crate) fn provide(providers: &mut Providers) {
1212
macro_rules! rtry {
1313
($e:expr) => {
1414
match $e {
15-
e @ Representability::Infinite => return e,
15+
e @ Representability::Infinite(_) => return e,
1616
Representability::Representable => {}
1717
}
1818
};

compiler/rustc_ty_utils/src/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ fn adt_sized_constraint<'tcx>(
9999
def_id: DefId,
100100
) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
101101
if let Some(def_id) = def_id.as_local() {
102-
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
103-
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_misc_error(tcx)]));
102+
if let ty::Representability::Infinite(guar) = tcx.representability(def_id) {
103+
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_error(tcx, guar)]));
104104
}
105105
}
106106
let def = tcx.adt_def(def_id);

0 commit comments

Comments
 (0)