]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/mir/type_foldable.rs
Rollup merge of #104669 - LeSeulArtichaut:88015-if-let-guard-bindings, r=cjgillot
[rust.git] / compiler / rustc_middle / src / mir / type_foldable.rs
1 //! `TypeFoldable` implementations for MIR types
2
3 use rustc_ast::InlineAsmTemplatePiece;
4
5 use super::*;
6 use crate::ty;
7
8 TrivialTypeTraversalAndLiftImpls! {
9     BlockTailInfo,
10     MirPhase,
11     SourceInfo,
12     FakeReadCause,
13     RetagKind,
14     SourceScope,
15     SourceScopeLocalData,
16     UserTypeAnnotationIndex,
17     BorrowKind,
18     CastKind,
19     BinOp,
20     NullOp,
21     UnOp,
22     hir::Movability,
23     BasicBlock,
24     SwitchTargets,
25     GeneratorKind,
26     GeneratorSavedLocal,
27 }
28
29 TrivialTypeTraversalImpls! {
30     for <'tcx> {
31         ConstValue<'tcx>,
32     }
33 }
34
35 impl<'tcx> TypeFoldable<'tcx> for &'tcx [InlineAsmTemplatePiece] {
36     fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
37         Ok(self)
38     }
39 }
40
41 impl<'tcx> TypeFoldable<'tcx> for &'tcx [Span] {
42     fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
43         Ok(self)
44     }
45 }
46
47 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
48     fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
49         ty::util::fold_list(self, folder, |tcx, v| tcx.intern_place_elems(v))
50     }
51 }
52
53 impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
54     fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
55         Ok(self)
56     }
57 }