Skip to content

Commit

Permalink
make Representability::Infinite carry ErrorGuaranteed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Markeffsky committed Mar 14, 2024
1 parent cb580ff commit d1ec4eb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,5 +601,5 @@ impl<'tcx> AdtDef<'tcx> {
#[derive(HashStable)]
pub enum Representability {
Representable,
Infinite,
Infinite(ErrorGuaranteed),
}
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/inhabitedness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub(crate) fn provide(providers: &mut Providers) {
/// requires calling [`InhabitedPredicate::instantiate`]
fn inhabited_predicate_adt(tcx: TyCtxt<'_>, def_id: DefId) -> InhabitedPredicate<'_> {
if let Some(def_id) = def_id.as_local() {
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
if matches!(tcx.representability(def_id), ty::Representability::Infinite(_)) {
return InhabitedPredicate::True;
}
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_middle/src/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
representable_ids.insert(def_id);
}
}
recursive_type_error(tcx, item_and_field_ids, &representable_ids);
Representability::Infinite
let guar = recursive_type_error(tcx, item_and_field_ids, &representable_ids);
Representability::Infinite(guar)
}
}

Expand Down Expand Up @@ -268,7 +268,7 @@ pub fn recursive_type_error(
tcx: TyCtxt<'_>,
mut item_and_field_ids: Vec<(LocalDefId, LocalDefId)>,
representable_ids: &FxHashSet<LocalDefId>,
) {
) -> ErrorGuaranteed {
const ITEM_LIMIT: usize = 5;

// Rotate the cycle so that the item with the lowest span is first
Expand Down Expand Up @@ -344,7 +344,7 @@ pub fn recursive_type_error(
suggestion,
Applicability::HasPlaceholders,
)
.emit();
.emit()
}

fn find_item_ty_spans(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ty_utils/src/representability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub(crate) fn provide(providers: &mut Providers) {
macro_rules! rtry {
($e:expr) => {
match $e {
e @ Representability::Infinite => return e,
e @ Representability::Infinite(_) => return e,
Representability::Representable => {}
}
};
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ty_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ fn adt_sized_constraint<'tcx>(
def_id: DefId,
) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
if let Some(def_id) = def_id.as_local() {
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_misc_error(tcx)]));
if let ty::Representability::Infinite(guar) = tcx.representability(def_id) {
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_error(tcx, guar)]));
}
}
let def = tcx.adt_def(def_id);
Expand Down

0 comments on commit d1ec4eb

Please sign in to comment.