Skip to content

Commit 6ba2dfd

Browse files
committed
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.
1 parent ca7585a commit 6ba2dfd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/rustc_middle/src/mir/type_foldable.rs

+4
Original file line numberDiff line numberDiff line change
@@ -406,4 +406,8 @@ impl<'tcx> TypeFoldable<'tcx> for ConstantKind<'tcx> {
406406
ConstantKind::Val(_, t) => t.visit_with(visitor),
407407
}
408408
}
409+
410+
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
411+
visitor.visit_mir_const(*self)
412+
}
409413
}

compiler/rustc_middle/src/ty/fold.rs

+4
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ pub trait TypeVisitor<'tcx>: Sized {
392392
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
393393
p.super_visit_with(self)
394394
}
395+
396+
fn visit_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> ControlFlow<Self::BreakTy> {
397+
c.super_visit_with(self)
398+
}
395399
}
396400

397401
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)