1 use crate::ty::{self, Ty, TyCtxt, AdtSizedConstraint};
2 use crate::ty::util::NeedsDrop;
4 use syntax::symbol::InternedString;
6 pub(super) trait Value<'tcx>: Sized {
7 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self;
10 impl<'tcx, T> Value<'tcx> for T {
11 default fn from_cycle_error(tcx: TyCtxt<'tcx>) -> T {
12 tcx.sess.abort_if_errors();
13 bug!("Value::from_cycle_error called without errors");
17 impl<'tcx> Value<'tcx> for Ty<'tcx> {
18 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
23 impl<'tcx> Value<'tcx> for ty::SymbolName {
24 fn from_cycle_error(_: TyCtxt<'tcx>) -> Self {
25 ty::SymbolName { name: InternedString::intern("<error>") }
29 impl<'tcx> Value<'tcx> for NeedsDrop {
30 fn from_cycle_error(_: TyCtxt<'tcx>) -> Self {
35 impl<'tcx> Value<'tcx> for AdtSizedConstraint<'tcx> {
36 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self {
37 AdtSizedConstraint(tcx.intern_type_list(&[tcx.types.err]))