1 use rustc_middle::ty::{self, AdtSizedConstraint, Ty, TyCtxt};
2 use rustc_query_system::Value;
4 impl<'tcx> Value<TyCtxt<'tcx>> for Ty<'_> {
5 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self {
6 // SAFETY: This is never called when `Self` is not `Ty<'tcx>`.
7 // FIXME: Represent the above fact in the trait system somehow.
8 unsafe { std::mem::transmute::<Ty<'tcx>, Ty<'_>>(tcx.ty_error()) }
12 impl<'tcx> Value<TyCtxt<'tcx>> for ty::SymbolName<'_> {
13 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self {
14 // SAFETY: This is never called when `Self` is not `SymbolName<'tcx>`.
15 // FIXME: Represent the above fact in the trait system somehow.
17 std::mem::transmute::<ty::SymbolName<'tcx>, ty::SymbolName<'_>>(ty::SymbolName::new(
24 impl<'tcx> Value<TyCtxt<'tcx>> for AdtSizedConstraint<'_> {
25 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self {
26 // SAFETY: This is never called when `Self` is not `AdtSizedConstraint<'tcx>`.
27 // FIXME: Represent the above fact in the trait system somehow.
29 std::mem::transmute::<AdtSizedConstraint<'tcx>, AdtSizedConstraint<'_>>(
30 AdtSizedConstraint(tcx.intern_type_list(&[tcx.ty_error()])),
36 impl<'tcx> Value<TyCtxt<'tcx>> for ty::Binder<'_, ty::FnSig<'_>> {
37 fn from_cycle_error(tcx: TyCtxt<'tcx>) -> Self {
38 let err = tcx.ty_error();
39 // FIXME(compiler-errors): It would be nice if we could get the
40 // query key, so we could at least generate a fn signature that
41 // has the right arity.
42 let fn_sig = ty::Binder::dummy(tcx.mk_fn_sig(
46 rustc_hir::Unsafety::Normal,
47 rustc_target::spec::abi::Abi::Rust,
50 // SAFETY: This is never called when `Self` is not `ty::Binder<'tcx, ty::FnSig<'tcx>>`.
51 // FIXME: Represent the above fact in the trait system somehow.
52 unsafe { std::mem::transmute::<ty::PolyFnSig<'tcx>, ty::Binder<'_, ty::FnSig<'_>>>(fn_sig) }