1 //! `TypeFoldable` implementations for MIR types
3 use rustc_ast::InlineAsmTemplatePiece;
9 TrivialTypeTraversalAndLiftImpls! {
17 UserTypeAnnotationIndex,
30 impl<'tcx> TypeFoldable<'tcx> for &'tcx [InlineAsmTemplatePiece] {
31 fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
36 impl<'tcx> TypeFoldable<'tcx> for &'tcx [Span] {
37 fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
42 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
43 fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
44 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_place_elems(v))
48 impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
49 fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
54 impl<'tcx> TypeFoldable<'tcx> for mir::UnevaluatedConst<'tcx> {
55 fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
56 folder.try_fold_mir_unevaluated(self)
60 impl<'tcx> TypeSuperFoldable<'tcx> for mir::UnevaluatedConst<'tcx> {
61 fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
64 ) -> Result<Self, F::Error> {
65 Ok(mir::UnevaluatedConst {
67 substs: self.substs.try_fold_with(folder)?,
68 promoted: self.promoted,
73 impl<'tcx> TypeFoldable<'tcx> for ConstantKind<'tcx> {
75 fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
76 folder.try_fold_mir_const(self)
80 impl<'tcx> TypeSuperFoldable<'tcx> for ConstantKind<'tcx> {
81 fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
84 ) -> Result<Self, F::Error> {
86 ConstantKind::Ty(c) => Ok(ConstantKind::Ty(c.try_fold_with(folder)?)),
87 ConstantKind::Val(v, t) => Ok(ConstantKind::Val(v, t.try_fold_with(folder)?)),
88 ConstantKind::Unevaluated(uv, t) => {
89 Ok(ConstantKind::Unevaluated(uv.try_fold_with(folder)?, t.try_fold_with(folder)?))