]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_middle/src/mir/type_visitable.rs
Rollup merge of #101717 - Pointerbender:unsafecell-memory-layout, r=Amanieu
[rust.git] / compiler / rustc_middle / src / mir / type_visitable.rs
1 //! `TypeVisitable` implementations for MIR types
2
3 use super::*;
4 use crate::mir;
5
6 impl<'tcx, R: Idx, C: Idx> TypeVisitable<'tcx> for BitMatrix<R, C> {
7     fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
8         ControlFlow::CONTINUE
9     }
10 }
11
12 impl<'tcx> TypeVisitable<'tcx> for mir::UnevaluatedConst<'tcx> {
13     fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
14         visitor.visit_mir_unevaluated(*self)
15     }
16 }
17
18 impl<'tcx> TypeSuperVisitable<'tcx> for mir::UnevaluatedConst<'tcx> {
19     fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
20         self.substs.visit_with(visitor)
21     }
22 }
23
24 impl<'tcx> TypeVisitable<'tcx> for ConstantKind<'tcx> {
25     fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
26         visitor.visit_mir_const(*self)
27     }
28 }
29
30 impl<'tcx> TypeSuperVisitable<'tcx> for ConstantKind<'tcx> {
31     fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
32         match *self {
33             ConstantKind::Ty(c) => c.visit_with(visitor),
34             ConstantKind::Val(_, t) => t.visit_with(visitor),
35             ConstantKind::Unevaluated(uv, t) => {
36                 uv.visit_with(visitor)?;
37                 t.visit_with(visitor)
38             }
39         }
40     }
41 }