about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-06-01 10:48:34 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-06-08 09:22:23 +1000
commit6ba2dfd3305e44af7ab3a1a7f6085a236c009caa (patch)
treeb03a6b76ad1ffa667deabcbfa232c33ab8b93b0a
parentca7585ab9a5c770eacf22dfcdbbe1ad72d8eab34 (diff)
downloadrust-6ba2dfd3305e44af7ab3a1a7f6085a236c009caa.tar.gz
rust-6ba2dfd3305e44af7ab3a1a7f6085a236c009caa.zip
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.
-rw-r--r--compiler/rustc_middle/src/mir/type_foldable.rs4
-rw-r--r--compiler/rustc_middle/src/ty/fold.rs4
2 files changed, 8 insertions, 0 deletions
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<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
+        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<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)
+    }
 }
 
 ///////////////////////////////////////////////////////////////////////////