change visit to fold for ty and reg

This commit is contained in:
ouz-a
2023-09-28 19:21:12 +03:00
parent fed72e0664
commit 9f2e15d232

View File

@@ -12,13 +12,13 @@ use super::ty::{
pub trait Folder: Sized {
type Break;
fn visit_ty(&mut self, ty: &Ty) -> ControlFlow<Self::Break, Ty> {
fn fold_ty(&mut self, ty: &Ty) -> ControlFlow<Self::Break, Ty> {
ty.super_fold(self)
}
fn fold_const(&mut self, c: &Const) -> ControlFlow<Self::Break, Const> {
c.super_fold(self)
}
fn visit_reg(&mut self, reg: &Region) -> ControlFlow<Self::Break, Region> {
fn fold_reg(&mut self, reg: &Region) -> ControlFlow<Self::Break, Region> {
reg.super_fold(self)
}
}
@@ -32,7 +32,7 @@ pub trait Foldable: Sized + Clone {
impl Foldable for Ty {
fn fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
folder.visit_ty(self)
folder.fold_ty(self)
}
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
let mut kind = self.kind();
@@ -114,7 +114,7 @@ impl Foldable for GenericArgs {
impl Foldable for Region {
fn fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
folder.visit_reg(self)
folder.fold_reg(self)
}
fn super_fold<V: Folder>(&self, folder: &mut V) -> ControlFlow<V::Break, Self> {
let mut kind = self.kind.clone();
@@ -257,7 +257,7 @@ pub enum Never {}
impl Folder for GenericArgs {
type Break = Never;
fn visit_ty(&mut self, ty: &Ty) -> ControlFlow<Self::Break, Ty> {
fn fold_ty(&mut self, ty: &Ty) -> ControlFlow<Self::Break, Ty> {
ControlFlow::Continue(match ty.kind() {
TyKind::Param(p) => self[p],
_ => *ty,