Add TypeVisitor::visit_mir_const.

Because `TypeFoldable::try_fold_mir_const` exists, and even though
`visit_mir_const` isn't needed right now, the consistency makes the code
easier to understand.
This commit is contained in:
Nicholas Nethercote 2022-06-01 10:48:34 +10:00
parent ca7585ab9a
commit 6ba2dfd330
2 changed files with 8 additions and 0 deletions

View File

@ -406,4 +406,8 @@ impl<'tcx> TypeFoldable<'tcx> for ConstantKind<'tcx> {
ConstantKind::Val(_, t) => t.visit_with(visitor),
}
}
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
visitor.visit_mir_const(*self)
}
}

View File

@ -392,6 +392,10 @@ pub trait TypeVisitor<'tcx>: Sized {
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
p.super_visit_with(self)
}
fn visit_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> ControlFlow<Self::BreakTy> {
c.super_visit_with(self)
}
}
///////////////////////////////////////////////////////////////////////////