mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
make Representability::Infinite
carry ErrorGuaranteed
This commit is contained in:
parent
30f74ff0dc
commit
0e7e1bfdbc
@ -601,5 +601,5 @@ impl<'tcx> AdtDef<'tcx> {
|
|||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
pub enum Representability {
|
pub enum Representability {
|
||||||
Representable,
|
Representable,
|
||||||
Infinite,
|
Infinite(ErrorGuaranteed),
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ pub(crate) fn provide(providers: &mut Providers) {
|
|||||||
/// requires calling [`InhabitedPredicate::instantiate`]
|
/// requires calling [`InhabitedPredicate::instantiate`]
|
||||||
fn inhabited_predicate_adt(tcx: TyCtxt<'_>, def_id: DefId) -> InhabitedPredicate<'_> {
|
fn inhabited_predicate_adt(tcx: TyCtxt<'_>, def_id: DefId) -> InhabitedPredicate<'_> {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
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;
|
return InhabitedPredicate::True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,8 @@ impl<'tcx> Value<TyCtxt<'tcx>> for Representability {
|
|||||||
representable_ids.insert(def_id);
|
representable_ids.insert(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recursive_type_error(tcx, item_and_field_ids, &representable_ids);
|
let guar = recursive_type_error(tcx, item_and_field_ids, &representable_ids);
|
||||||
Representability::Infinite
|
Representability::Infinite(guar)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ pub fn recursive_type_error(
|
|||||||
tcx: TyCtxt<'_>,
|
tcx: TyCtxt<'_>,
|
||||||
mut item_and_field_ids: Vec<(LocalDefId, LocalDefId)>,
|
mut item_and_field_ids: Vec<(LocalDefId, LocalDefId)>,
|
||||||
representable_ids: &FxHashSet<LocalDefId>,
|
representable_ids: &FxHashSet<LocalDefId>,
|
||||||
) {
|
) -> ErrorGuaranteed {
|
||||||
const ITEM_LIMIT: usize = 5;
|
const ITEM_LIMIT: usize = 5;
|
||||||
|
|
||||||
// Rotate the cycle so that the item with the lowest span is first
|
// Rotate the cycle so that the item with the lowest span is first
|
||||||
@ -344,7 +344,7 @@ pub fn recursive_type_error(
|
|||||||
suggestion,
|
suggestion,
|
||||||
Applicability::HasPlaceholders,
|
Applicability::HasPlaceholders,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_item_ty_spans(
|
fn find_item_ty_spans(
|
||||||
|
@ -12,7 +12,7 @@ pub(crate) fn provide(providers: &mut Providers) {
|
|||||||
macro_rules! rtry {
|
macro_rules! rtry {
|
||||||
($e:expr) => {
|
($e:expr) => {
|
||||||
match $e {
|
match $e {
|
||||||
e @ Representability::Infinite => return e,
|
e @ Representability::Infinite(_) => return e,
|
||||||
Representability::Representable => {}
|
Representability::Representable => {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -99,8 +99,8 @@ fn adt_sized_constraint<'tcx>(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
||||||
if let Some(def_id) = def_id.as_local() {
|
if let Some(def_id) = def_id.as_local() {
|
||||||
if matches!(tcx.representability(def_id), ty::Representability::Infinite) {
|
if let ty::Representability::Infinite(guar) = tcx.representability(def_id) {
|
||||||
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_misc_error(tcx)]));
|
return ty::EarlyBinder::bind(tcx.mk_type_list(&[Ty::new_error(tcx, guar)]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let def = tcx.adt_def(def_id);
|
let def = tcx.adt_def(def_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user