Skip to content

Commit 26afc4f

Browse files
committed
Allow fallible lift_to_global in existential type writeback
1 parent cff1bdb commit 26afc4f

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

src/librustc_typeck/check/writeback.rs

+26-19
Original file line numberDiff line numberDiff line change
@@ -611,26 +611,33 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
611611
}
612612
}
613613

614-
let new = ty::ResolvedOpaqueTy {
615-
concrete_type: definition_ty,
616-
substs: self.tcx().lift_to_global(&opaque_defn.substs).unwrap(),
617-
};
618-
619-
let old = self.tables
620-
.concrete_existential_types
621-
.insert(def_id, new);
622-
if let Some(old) = old {
623-
if old.concrete_type != definition_ty || old.substs != opaque_defn.substs {
624-
span_bug!(
625-
span,
626-
"visit_opaque_types tried to write \
627-
different types for the same existential type: {:?}, {:?}, {:?}, {:?}",
628-
def_id,
629-
definition_ty,
630-
opaque_defn,
631-
old,
632-
);
614+
if let Some(substs) = self.tcx().lift_to_global(&opaque_defn.substs) {
615+
let new = ty::ResolvedOpaqueTy {
616+
concrete_type: definition_ty,
617+
substs,
618+
};
619+
620+
let old = self.tables
621+
.concrete_existential_types
622+
.insert(def_id, new);
623+
if let Some(old) = old {
624+
if old.concrete_type != definition_ty || old.substs != opaque_defn.substs {
625+
span_bug!(
626+
span,
627+
"visit_opaque_types tried to write \
628+
different types for the same existential type: {:?}, {:?}, {:?}, {:?}",
629+
def_id,
630+
definition_ty,
631+
opaque_defn,
632+
old,
633+
);
634+
}
633635
}
636+
} else {
637+
self.tcx().sess.delay_span_bug(
638+
span,
639+
"cannot lift `opaque_defn` substs to global type context",
640+
);
634641
}
635642
}
636643
}

0 commit comments

Comments
 (0)