From 6ba2dfd3305e44af7ab3a1a7f6085a236c009caa Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Wed, 1 Jun 2022 10:48:34 +1000 Subject: [PATCH] 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. --- compiler/rustc_middle/src/mir/type_foldable.rs | 4 ++++ compiler/rustc_middle/src/ty/fold.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index 14d4cb2c330..8f50ec4fe08 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -406,4 +406,8 @@ impl<'tcx> TypeFoldable<'tcx> for ConstantKind<'tcx> { ConstantKind::Val(_, t) => t.visit_with(visitor), } } + + fn visit_with>(&self, visitor: &mut V) -> ControlFlow { + visitor.visit_mir_const(*self) + } } diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index 5cf40ad3b8e..c2d640009c4 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -392,6 +392,10 @@ pub trait TypeVisitor<'tcx>: Sized { fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow { p.super_visit_with(self) } + + fn visit_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> ControlFlow { + c.super_visit_with(self) + } } ///////////////////////////////////////////////////////////////////////////