Actually visit/fold the types inside CanonicalVarInfos
This commit is contained in:
parent
cf6366baba
commit
18ab705073
@ -29,7 +29,7 @@
|
||||
use rustc_macros::HashStable;
|
||||
use smallvec::SmallVec;
|
||||
use std::iter;
|
||||
use std::ops::Index;
|
||||
use std::ops::{ControlFlow, Index};
|
||||
|
||||
/// A "canonicalized" type `V` is one where all free inference
|
||||
/// variables have been rewritten to "canonical vars". These are
|
||||
@ -44,6 +44,21 @@ pub struct Canonical<'tcx, V> {
|
||||
|
||||
pub type CanonicalVarInfos<'tcx> = &'tcx List<CanonicalVarInfo<'tcx>>;
|
||||
|
||||
impl<'tcx> ty::TypeFoldable<'tcx> for CanonicalVarInfos<'tcx> {
|
||||
fn try_fold_with<F: ty::FallibleTypeFolder<'tcx>>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self, F::Error> {
|
||||
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_canonical_var_infos(v))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::TypeVisitable<'tcx> for CanonicalVarInfos<'tcx> {
|
||||
fn visit_with<V: ty::TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||
}
|
||||
}
|
||||
|
||||
/// A set of values corresponding to the canonical variables from some
|
||||
/// `Canonical`. You can give these values to
|
||||
/// `canonical_value.substitute` to substitute them into the canonical
|
||||
@ -305,12 +320,6 @@ pub fn unchecked_map<W>(self, map_op: impl FnOnce(V) -> W) -> Canonical<'tcx, W>
|
||||
}
|
||||
}
|
||||
|
||||
TrivialTypeTraversalImpls! {
|
||||
for <'tcx> {
|
||||
crate::infer::canonical::CanonicalVarInfos<'tcx>,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> CanonicalVarValues<'tcx> {
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
|
Loading…
Reference in New Issue
Block a user