Skip to content

Commit 4ff22dd

Browse files
flodieboldjackh726
authored andcommitted
Move some TypeVisitable/TypeFoldable impls to rustc_type_ir
1 parent 8fb40f7 commit 4ff22dd

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

compiler/rustc_type_ir/src/const_kind.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
77
use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_NoContext};
88
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
99

10-
use crate::{self as ty, DebruijnIndex, Interner};
10+
use crate::{
11+
self as ty, DebruijnIndex, FallibleTypeFolder, Interner, TypeFoldable, TypeFolder,
12+
TypeVisitable, TypeVisitor, VisitorResult,
13+
};
1114

1215
/// Represents a constant in Rust.
1316
#[derive_where(Clone, Copy, Hash, PartialEq, Eq; I: Interner)]
@@ -120,3 +123,19 @@ impl<CTX> HashStable<CTX> for InferConst {
120123
}
121124
}
122125
}
126+
127+
impl<I: Interner> TypeFoldable<I> for InferConst {
128+
fn try_fold_with<F: FallibleTypeFolder<I>>(self, _folder: &mut F) -> Result<Self, F::Error> {
129+
Ok(self)
130+
}
131+
132+
fn fold_with<F: TypeFolder<I>>(self, _folder: &mut F) -> Self {
133+
self
134+
}
135+
}
136+
137+
impl<I: Interner> TypeVisitable<I> for InferConst {
138+
fn visit_with<V: TypeVisitor<I>>(&self, _visitor: &mut V) -> V::Result {
139+
V::Result::output()
140+
}
141+
}

0 commit comments

Comments
 (0)