1 //! This module contains implements of the `Lift` and `TypeFoldable`
2 //! traits for various types in the Rust compiler. Most are written by
3 //! hand, though we've recently added some macros and proc-macros to help with the tedium.
5 use crate::mir::interpret;
6 use crate::mir::ProjectionKind;
7 use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
8 use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
9 use crate::ty::{self, InferConst, Lift, Ty, TyCtxt};
10 use rustc_data_structures::functor::IdFunctor;
12 use rustc_hir::def::Namespace;
13 use rustc_hir::def_id::CRATE_DEF_INDEX;
14 use rustc_index::vec::{Idx, IndexVec};
17 use std::ops::ControlFlow;
21 impl fmt::Debug for ty::TraitDef {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 with_no_trimmed_paths(|| {
25 FmtPrinter::new(tcx, f, Namespace::TypeNS).print_def_path(self.def_id, &[])
32 impl fmt::Debug for ty::AdtDef {
33 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 with_no_trimmed_paths(|| {
36 FmtPrinter::new(tcx, f, Namespace::TypeNS).print_def_path(self.did, &[])
43 impl fmt::Debug for ty::UpvarId {
44 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45 let name = ty::tls::with(|tcx| tcx.hir().name(self.var_path.hir_id));
46 write!(f, "UpvarId({:?};`{}`;{:?})", self.var_path.hir_id, name, self.closure_expr_id)
50 impl fmt::Debug for ty::UpvarBorrow<'tcx> {
51 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52 write!(f, "UpvarBorrow({:?}, {:?})", self.kind, self.region)
56 impl fmt::Debug for ty::ExistentialTraitRef<'tcx> {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 with_no_trimmed_paths(|| fmt::Display::fmt(self, f))
62 impl fmt::Debug for ty::adjustment::Adjustment<'tcx> {
63 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
64 write!(f, "{:?} -> {}", self.kind, self.target)
68 impl fmt::Debug for ty::BoundRegion {
69 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
72 ty::BrNamed(did, name) => {
73 if did.index == CRATE_DEF_INDEX {
74 write!(f, "BrNamed({})", name)
76 write!(f, "BrNamed({:?}, {})", did, name)
79 ty::BrEnv => write!(f, "BrEnv"),
84 impl fmt::Debug for ty::RegionKind {
85 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87 ty::ReEarlyBound(ref data) => write!(f, "ReEarlyBound({}, {})", data.index, data.name),
89 ty::ReLateBound(binder_id, ref bound_region) => {
90 write!(f, "ReLateBound({:?}, {:?})", binder_id, bound_region)
93 ty::ReFree(ref fr) => fr.fmt(f),
95 ty::ReStatic => write!(f, "ReStatic"),
97 ty::ReVar(ref vid) => vid.fmt(f),
99 ty::RePlaceholder(placeholder) => write!(f, "RePlaceholder({:?})", placeholder),
101 ty::ReEmpty(ui) => write!(f, "ReEmpty({:?})", ui),
103 ty::ReErased => write!(f, "ReErased"),
108 impl fmt::Debug for ty::FreeRegion {
109 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110 write!(f, "ReFree({:?}, {:?})", self.scope, self.bound_region)
114 impl fmt::Debug for ty::Variance {
115 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
116 f.write_str(match *self {
117 ty::Covariant => "+",
118 ty::Contravariant => "-",
119 ty::Invariant => "o",
120 ty::Bivariant => "*",
125 impl fmt::Debug for ty::FnSig<'tcx> {
126 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
127 write!(f, "({:?}; c_variadic: {})->{:?}", self.inputs(), self.c_variadic, self.output())
131 impl fmt::Debug for ty::TyVid {
132 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
133 write!(f, "_#{}t", self.index)
137 impl<'tcx> fmt::Debug for ty::ConstVid<'tcx> {
138 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
139 write!(f, "_#{}c", self.index)
143 impl fmt::Debug for ty::IntVid {
144 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
145 write!(f, "_#{}i", self.index)
149 impl fmt::Debug for ty::FloatVid {
150 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
151 write!(f, "_#{}f", self.index)
155 impl fmt::Debug for ty::RegionVid {
156 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
157 write!(f, "'_#{}r", self.index())
161 impl fmt::Debug for ty::InferTy {
162 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
164 ty::TyVar(ref v) => v.fmt(f),
165 ty::IntVar(ref v) => v.fmt(f),
166 ty::FloatVar(ref v) => v.fmt(f),
167 ty::FreshTy(v) => write!(f, "FreshTy({:?})", v),
168 ty::FreshIntTy(v) => write!(f, "FreshIntTy({:?})", v),
169 ty::FreshFloatTy(v) => write!(f, "FreshFloatTy({:?})", v),
174 impl fmt::Debug for ty::IntVarValue {
175 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177 ty::IntType(ref v) => v.fmt(f),
178 ty::UintType(ref v) => v.fmt(f),
183 impl fmt::Debug for ty::FloatVarValue {
184 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
189 impl fmt::Debug for ty::TraitRef<'tcx> {
190 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
191 with_no_trimmed_paths(|| fmt::Display::fmt(self, f))
195 impl fmt::Debug for Ty<'tcx> {
196 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
197 with_no_trimmed_paths(|| fmt::Display::fmt(self, f))
201 impl fmt::Debug for ty::ParamTy {
202 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
203 write!(f, "{}/#{}", self.name, self.index)
207 impl fmt::Debug for ty::ParamConst {
208 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209 write!(f, "{}/#{}", self.name, self.index)
213 impl fmt::Debug for ty::TraitPredicate<'tcx> {
214 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
215 write!(f, "TraitPredicate({:?})", self.trait_ref)
219 impl fmt::Debug for ty::ProjectionPredicate<'tcx> {
220 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
221 write!(f, "ProjectionPredicate({:?}, {:?})", self.projection_ty, self.ty)
225 impl fmt::Debug for ty::Predicate<'tcx> {
226 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
227 write!(f, "{:?}", self.kind())
231 impl fmt::Debug for ty::PredicateKind<'tcx> {
232 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
234 ty::PredicateKind::ForAll(binder) => write!(f, "ForAll({:?})", binder),
235 ty::PredicateKind::Atom(atom) => write!(f, "{:?}", atom),
240 impl fmt::Debug for ty::PredicateAtom<'tcx> {
241 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
243 ty::PredicateAtom::Trait(ref a, constness) => {
244 if let hir::Constness::Const = constness {
245 write!(f, "const ")?;
249 ty::PredicateAtom::Subtype(ref pair) => pair.fmt(f),
250 ty::PredicateAtom::RegionOutlives(ref pair) => pair.fmt(f),
251 ty::PredicateAtom::TypeOutlives(ref pair) => pair.fmt(f),
252 ty::PredicateAtom::Projection(ref pair) => pair.fmt(f),
253 ty::PredicateAtom::WellFormed(data) => write!(f, "WellFormed({:?})", data),
254 ty::PredicateAtom::ObjectSafe(trait_def_id) => {
255 write!(f, "ObjectSafe({:?})", trait_def_id)
257 ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
258 write!(f, "ClosureKind({:?}, {:?}, {:?})", closure_def_id, closure_substs, kind)
260 ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
261 write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)
263 ty::PredicateAtom::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
264 ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
265 write!(f, "TypeWellFormedFromEnv({:?})", ty)
271 ///////////////////////////////////////////////////////////////////////////
274 // For things that don't carry any arena-allocated data (and are
275 // copy...), just add them to this list.
277 TrivialTypeFoldableAndLiftImpls! {
281 ::rustc_target::abi::VariantIdx,
285 crate::middle::region::Scope,
286 ::rustc_ast::FloatTy,
287 ::rustc_ast::InlineAsmOptions,
288 ::rustc_ast::InlineAsmTemplatePiece,
290 ::rustc_span::symbol::Symbol,
291 ::rustc_hir::def::Res,
292 ::rustc_hir::def_id::DefId,
293 ::rustc_hir::def_id::LocalDefId,
295 ::rustc_hir::LlvmInlineAsmInner,
296 ::rustc_hir::MatchSource,
297 ::rustc_hir::Mutability,
298 ::rustc_hir::Unsafety,
299 ::rustc_target::asm::InlineAsmRegOrRegClass,
300 ::rustc_target::spec::abi::Abi,
301 crate::mir::coverage::ExpressionOperandId,
302 crate::mir::coverage::CounterValueReference,
303 crate::mir::coverage::InjectedExpressionId,
304 crate::mir::coverage::InjectedExpressionIndex,
305 crate::mir::coverage::MappedExpressionIndex,
307 crate::mir::Promoted,
308 crate::traits::Reveal,
309 crate::ty::adjustment::AutoBorrowMutability,
311 // Including `BoundRegion` is a *bit* dubious, but direct
312 // references to bound region appear in `ty::Error`, and aren't
313 // really meant to be folded. In general, we can only fold a fully
315 crate::ty::BoundRegion,
316 crate::ty::AssocItem,
317 crate::ty::Placeholder<crate::ty::BoundRegion>,
318 crate::ty::ClosureKind,
319 crate::ty::FreeRegion,
321 crate::ty::IntVarValue,
322 crate::ty::ParamConst,
324 crate::ty::adjustment::PointerCast,
325 crate::ty::RegionVid,
326 crate::ty::UniverseIndex,
331 ///////////////////////////////////////////////////////////////////////////
332 // Lift implementations
334 // FIXME(eddyb) replace all the uses of `Option::map` with `?`.
335 impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
336 type Lifted = (A::Lifted, B::Lifted);
337 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
338 Some((tcx.lift(self.0)?, tcx.lift(self.1)?))
342 impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>, C: Lift<'tcx>> Lift<'tcx> for (A, B, C) {
343 type Lifted = (A::Lifted, B::Lifted, C::Lifted);
344 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
345 Some((tcx.lift(self.0)?, tcx.lift(self.1)?, tcx.lift(self.2)?))
349 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
350 type Lifted = Option<T::Lifted>;
351 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
353 Some(x) => tcx.lift(x).map(Some),
359 impl<'tcx, T: Lift<'tcx>, E: Lift<'tcx>> Lift<'tcx> for Result<T, E> {
360 type Lifted = Result<T::Lifted, E::Lifted>;
361 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
363 Ok(x) => tcx.lift(x).map(Ok),
364 Err(e) => tcx.lift(e).map(Err),
369 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Box<T> {
370 type Lifted = Box<T::Lifted>;
371 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
372 tcx.lift(*self).map(Box::new)
376 impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Rc<T> {
377 type Lifted = Rc<T::Lifted>;
378 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
379 tcx.lift(self.as_ref().clone()).map(Rc::new)
383 impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Arc<T> {
384 type Lifted = Arc<T::Lifted>;
385 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
386 tcx.lift(self.as_ref().clone()).map(Arc::new)
389 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec<T> {
390 type Lifted = Vec<T::Lifted>;
391 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
392 self.into_iter().map(|v| tcx.lift(v)).collect()
396 impl<'tcx, I: Idx, T: Lift<'tcx>> Lift<'tcx> for IndexVec<I, T> {
397 type Lifted = IndexVec<I, T::Lifted>;
398 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
399 self.into_iter().map(|e| tcx.lift(e)).collect()
403 impl<'a, 'tcx> Lift<'tcx> for ty::TraitRef<'a> {
404 type Lifted = ty::TraitRef<'tcx>;
405 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
406 tcx.lift(self.substs).map(|substs| ty::TraitRef { def_id: self.def_id, substs })
410 impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialTraitRef<'a> {
411 type Lifted = ty::ExistentialTraitRef<'tcx>;
412 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
413 tcx.lift(self.substs).map(|substs| ty::ExistentialTraitRef { def_id: self.def_id, substs })
417 impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> {
418 type Lifted = ty::ExistentialPredicate<'tcx>;
419 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
421 ty::ExistentialPredicate::Trait(x) => tcx.lift(x).map(ty::ExistentialPredicate::Trait),
422 ty::ExistentialPredicate::Projection(x) => {
423 tcx.lift(x).map(ty::ExistentialPredicate::Projection)
425 ty::ExistentialPredicate::AutoTrait(def_id) => {
426 Some(ty::ExistentialPredicate::AutoTrait(def_id))
432 impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
433 type Lifted = ty::TraitPredicate<'tcx>;
434 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
435 tcx.lift(self.trait_ref).map(|trait_ref| ty::TraitPredicate { trait_ref })
439 impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
440 type Lifted = ty::SubtypePredicate<'tcx>;
441 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::SubtypePredicate<'tcx>> {
442 tcx.lift((self.a, self.b)).map(|(a, b)| ty::SubtypePredicate {
443 a_is_expected: self.a_is_expected,
450 impl<'tcx, A: Copy + Lift<'tcx>, B: Copy + Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
451 type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
452 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
453 tcx.lift((self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
457 impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
458 type Lifted = ty::ProjectionTy<'tcx>;
459 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::ProjectionTy<'tcx>> {
460 tcx.lift(self.substs)
461 .map(|substs| ty::ProjectionTy { item_def_id: self.item_def_id, substs })
465 impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
466 type Lifted = ty::ProjectionPredicate<'tcx>;
467 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> {
468 tcx.lift((self.projection_ty, self.ty))
469 .map(|(projection_ty, ty)| ty::ProjectionPredicate { projection_ty, ty })
473 impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialProjection<'a> {
474 type Lifted = ty::ExistentialProjection<'tcx>;
475 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
476 tcx.lift(self.substs).map(|substs| ty::ExistentialProjection {
478 ty: tcx.lift(self.ty).expect("type must lift when substs do"),
479 item_def_id: self.item_def_id,
484 impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
485 type Lifted = ty::PredicateKind<'tcx>;
486 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
488 ty::PredicateKind::ForAll(binder) => tcx.lift(binder).map(ty::PredicateKind::ForAll),
489 ty::PredicateKind::Atom(atom) => tcx.lift(atom).map(ty::PredicateKind::Atom),
494 impl<'a, 'tcx> Lift<'tcx> for ty::PredicateAtom<'a> {
495 type Lifted = ty::PredicateAtom<'tcx>;
496 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
498 ty::PredicateAtom::Trait(data, constness) => {
499 tcx.lift(data).map(|data| ty::PredicateAtom::Trait(data, constness))
501 ty::PredicateAtom::Subtype(data) => tcx.lift(data).map(ty::PredicateAtom::Subtype),
502 ty::PredicateAtom::RegionOutlives(data) => {
503 tcx.lift(data).map(ty::PredicateAtom::RegionOutlives)
505 ty::PredicateAtom::TypeOutlives(data) => {
506 tcx.lift(data).map(ty::PredicateAtom::TypeOutlives)
508 ty::PredicateAtom::Projection(data) => {
509 tcx.lift(data).map(ty::PredicateAtom::Projection)
511 ty::PredicateAtom::WellFormed(ty) => tcx.lift(ty).map(ty::PredicateAtom::WellFormed),
512 ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
513 tcx.lift(closure_substs).map(|closure_substs| {
514 ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind)
517 ty::PredicateAtom::ObjectSafe(trait_def_id) => {
518 Some(ty::PredicateAtom::ObjectSafe(trait_def_id))
520 ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
521 tcx.lift(substs).map(|substs| ty::PredicateAtom::ConstEvaluatable(def_id, substs))
523 ty::PredicateAtom::ConstEquate(c1, c2) => {
524 tcx.lift((c1, c2)).map(|(c1, c2)| ty::PredicateAtom::ConstEquate(c1, c2))
526 ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
527 tcx.lift(ty).map(ty::PredicateAtom::TypeWellFormedFromEnv)
533 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
534 type Lifted = ty::Binder<T::Lifted>;
535 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
536 self.map_bound(|v| tcx.lift(v)).transpose()
540 impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
541 type Lifted = ty::ParamEnv<'tcx>;
542 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
543 tcx.lift(self.caller_bounds())
544 .map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal()))
548 impl<'a, 'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::ParamEnvAnd<'a, T> {
549 type Lifted = ty::ParamEnvAnd<'tcx, T::Lifted>;
550 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
551 tcx.lift(self.param_env).and_then(|param_env| {
552 tcx.lift(self.value).map(|value| ty::ParamEnvAnd { param_env, value })
557 impl<'a, 'tcx> Lift<'tcx> for ty::ClosureSubsts<'a> {
558 type Lifted = ty::ClosureSubsts<'tcx>;
559 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
560 tcx.lift(self.substs).map(|substs| ty::ClosureSubsts { substs })
564 impl<'a, 'tcx> Lift<'tcx> for ty::GeneratorSubsts<'a> {
565 type Lifted = ty::GeneratorSubsts<'tcx>;
566 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
567 tcx.lift(self.substs).map(|substs| ty::GeneratorSubsts { substs })
571 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjustment<'a> {
572 type Lifted = ty::adjustment::Adjustment<'tcx>;
573 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
574 let ty::adjustment::Adjustment { kind, target } = self;
575 tcx.lift(kind).and_then(|kind| {
576 tcx.lift(target).map(|target| ty::adjustment::Adjustment { kind, target })
581 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjust<'a> {
582 type Lifted = ty::adjustment::Adjust<'tcx>;
583 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
585 ty::adjustment::Adjust::NeverToAny => Some(ty::adjustment::Adjust::NeverToAny),
586 ty::adjustment::Adjust::Pointer(ptr) => Some(ty::adjustment::Adjust::Pointer(ptr)),
587 ty::adjustment::Adjust::Deref(overloaded) => {
588 tcx.lift(overloaded).map(ty::adjustment::Adjust::Deref)
590 ty::adjustment::Adjust::Borrow(autoref) => {
591 tcx.lift(autoref).map(ty::adjustment::Adjust::Borrow)
597 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::OverloadedDeref<'a> {
598 type Lifted = ty::adjustment::OverloadedDeref<'tcx>;
599 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
600 tcx.lift(self.region).map(|region| ty::adjustment::OverloadedDeref {
608 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> {
609 type Lifted = ty::adjustment::AutoBorrow<'tcx>;
610 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
612 ty::adjustment::AutoBorrow::Ref(r, m) => {
613 tcx.lift(r).map(|r| ty::adjustment::AutoBorrow::Ref(r, m))
615 ty::adjustment::AutoBorrow::RawPtr(m) => Some(ty::adjustment::AutoBorrow::RawPtr(m)),
620 impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> {
621 type Lifted = ty::GenSig<'tcx>;
622 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
623 tcx.lift((self.resume_ty, self.yield_ty, self.return_ty))
624 .map(|(resume_ty, yield_ty, return_ty)| ty::GenSig { resume_ty, yield_ty, return_ty })
628 impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> {
629 type Lifted = ty::FnSig<'tcx>;
630 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
631 tcx.lift(self.inputs_and_output).map(|x| ty::FnSig {
632 inputs_and_output: x,
633 c_variadic: self.c_variadic,
634 unsafety: self.unsafety,
640 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::error::ExpectedFound<T> {
641 type Lifted = ty::error::ExpectedFound<T::Lifted>;
642 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
643 let ty::error::ExpectedFound { expected, found } = self;
644 tcx.lift(expected).and_then(|expected| {
645 tcx.lift(found).map(|found| ty::error::ExpectedFound { expected, found })
650 impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> {
651 type Lifted = ty::error::TypeError<'tcx>;
652 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
653 use crate::ty::error::TypeError::*;
656 Mismatch => Mismatch,
657 UnsafetyMismatch(x) => UnsafetyMismatch(x),
658 AbiMismatch(x) => AbiMismatch(x),
659 Mutability => Mutability,
660 TupleSize(x) => TupleSize(x),
661 FixedArraySize(x) => FixedArraySize(x),
662 ArgCount => ArgCount,
663 RegionsDoesNotOutlive(a, b) => {
664 return tcx.lift((a, b)).map(|(a, b)| RegionsDoesNotOutlive(a, b));
666 RegionsInsufficientlyPolymorphic(a, b) => {
667 return tcx.lift(b).map(|b| RegionsInsufficientlyPolymorphic(a, b));
669 RegionsOverlyPolymorphic(a, b) => {
670 return tcx.lift(b).map(|b| RegionsOverlyPolymorphic(a, b));
672 RegionsPlaceholderMismatch => RegionsPlaceholderMismatch,
673 IntMismatch(x) => IntMismatch(x),
674 FloatMismatch(x) => FloatMismatch(x),
675 Traits(x) => Traits(x),
676 VariadicMismatch(x) => VariadicMismatch(x),
677 CyclicTy(t) => return tcx.lift(t).map(|t| CyclicTy(t)),
678 CyclicConst(ct) => return tcx.lift(ct).map(|ct| CyclicConst(ct)),
679 ProjectionMismatched(x) => ProjectionMismatched(x),
680 Sorts(x) => return tcx.lift(x).map(Sorts),
681 ExistentialMismatch(x) => return tcx.lift(x).map(ExistentialMismatch),
682 ConstMismatch(x) => return tcx.lift(x).map(ConstMismatch),
683 IntrinsicCast => IntrinsicCast,
684 TargetFeatureCast(x) => TargetFeatureCast(x),
685 ObjectUnsafeCoercion(x) => return tcx.lift(x).map(ObjectUnsafeCoercion),
690 impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
691 type Lifted = ty::InstanceDef<'tcx>;
692 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
694 ty::InstanceDef::Item(def_id) => Some(ty::InstanceDef::Item(def_id)),
695 ty::InstanceDef::VtableShim(def_id) => Some(ty::InstanceDef::VtableShim(def_id)),
696 ty::InstanceDef::ReifyShim(def_id) => Some(ty::InstanceDef::ReifyShim(def_id)),
697 ty::InstanceDef::Intrinsic(def_id) => Some(ty::InstanceDef::Intrinsic(def_id)),
698 ty::InstanceDef::FnPtrShim(def_id, ty) => {
699 Some(ty::InstanceDef::FnPtrShim(def_id, tcx.lift(ty)?))
701 ty::InstanceDef::Virtual(def_id, n) => Some(ty::InstanceDef::Virtual(def_id, n)),
702 ty::InstanceDef::ClosureOnceShim { call_once } => {
703 Some(ty::InstanceDef::ClosureOnceShim { call_once })
705 ty::InstanceDef::DropGlue(def_id, ty) => {
706 Some(ty::InstanceDef::DropGlue(def_id, tcx.lift(ty)?))
708 ty::InstanceDef::CloneShim(def_id, ty) => {
709 Some(ty::InstanceDef::CloneShim(def_id, tcx.lift(ty)?))
715 ///////////////////////////////////////////////////////////////////////////
716 // TypeFoldable implementations.
718 // Ideally, each type should invoke `folder.fold_foo(self)` and
719 // nothing else. In some cases, though, we haven't gotten around to
720 // adding methods on the `folder` yet, and thus the folding is
721 // hard-coded here. This is less-flexible, because folders cannot
722 // override the behavior, but there are a lot of random types and one
723 // can easily refactor the folding into the TypeFolder trait as
726 /// AdtDefs are basically the same as a DefId.
727 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::AdtDef {
728 fn super_fold_with<F: TypeFolder<'tcx>>(self, _folder: &mut F) -> Self {
732 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
733 ControlFlow::CONTINUE
737 impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
738 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> (T, U) {
739 (self.0.fold_with(folder), self.1.fold_with(folder))
742 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
743 self.0.visit_with(visitor)?;
744 self.1.visit_with(visitor)
748 impl<'tcx, A: TypeFoldable<'tcx>, B: TypeFoldable<'tcx>, C: TypeFoldable<'tcx>> TypeFoldable<'tcx>
751 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> (A, B, C) {
752 (self.0.fold_with(folder), self.1.fold_with(folder), self.2.fold_with(folder))
755 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
756 self.0.visit_with(visitor)?;
757 self.1.visit_with(visitor)?;
758 self.2.visit_with(visitor)
762 EnumTypeFoldableImpl! {
763 impl<'tcx, T> TypeFoldable<'tcx> for Option<T> {
766 } where T: TypeFoldable<'tcx>
769 EnumTypeFoldableImpl! {
770 impl<'tcx, T, E> TypeFoldable<'tcx> for Result<T, E> {
773 } where T: TypeFoldable<'tcx>, E: TypeFoldable<'tcx>,
776 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc<T> {
777 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
778 // FIXME: Reuse the `Rc` here.
779 Rc::new((*self).clone().fold_with(folder))
782 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
783 (**self).visit_with(visitor)
787 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Arc<T> {
788 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
789 // FIXME: Reuse the `Arc` here.
790 Arc::new((*self).clone().fold_with(folder))
793 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
794 (**self).visit_with(visitor)
798 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<T> {
799 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
800 self.map_id(|value| value.fold_with(folder))
803 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
804 (**self).visit_with(visitor)
808 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
809 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
810 self.map_id(|t| t.fold_with(folder))
813 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
814 self.iter().try_for_each(|t| t.visit_with(visitor))
818 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> {
819 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
820 self.map_id(|t| t.fold_with(folder))
823 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
824 self.iter().try_for_each(|t| t.visit_with(visitor))
828 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
829 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
830 self.map_bound(|ty| ty.fold_with(folder))
833 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
834 folder.fold_binder(self)
837 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
838 self.as_ref().skip_binder().visit_with(visitor)
841 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
842 visitor.visit_binder(self)
846 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>> {
847 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
848 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v))
851 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
852 self.iter().try_for_each(|p| p.visit_with(visitor))
856 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
857 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
858 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_type_list(v))
861 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
862 self.iter().try_for_each(|t| t.visit_with(visitor))
866 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ProjectionKind> {
867 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
868 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v))
871 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
872 self.iter().try_for_each(|t| t.visit_with(visitor))
876 impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
877 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
878 use crate::ty::InstanceDef::*;
880 substs: self.substs.fold_with(folder),
881 def: match self.def {
882 Item(def) => Item(def.fold_with(folder)),
883 VtableShim(did) => VtableShim(did.fold_with(folder)),
884 ReifyShim(did) => ReifyShim(did.fold_with(folder)),
885 Intrinsic(did) => Intrinsic(did.fold_with(folder)),
886 FnPtrShim(did, ty) => FnPtrShim(did.fold_with(folder), ty.fold_with(folder)),
887 Virtual(did, i) => Virtual(did.fold_with(folder), i),
888 ClosureOnceShim { call_once } => {
889 ClosureOnceShim { call_once: call_once.fold_with(folder) }
891 DropGlue(did, ty) => DropGlue(did.fold_with(folder), ty.fold_with(folder)),
892 CloneShim(did, ty) => CloneShim(did.fold_with(folder), ty.fold_with(folder)),
897 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
898 use crate::ty::InstanceDef::*;
899 self.substs.visit_with(visitor)?;
901 Item(def) => def.visit_with(visitor),
902 VtableShim(did) | ReifyShim(did) | Intrinsic(did) | Virtual(did, _) => {
903 did.visit_with(visitor)
905 FnPtrShim(did, ty) | CloneShim(did, ty) => {
906 did.visit_with(visitor)?;
907 ty.visit_with(visitor)
909 DropGlue(did, ty) => {
910 did.visit_with(visitor)?;
911 ty.visit_with(visitor)
913 ClosureOnceShim { call_once } => call_once.visit_with(visitor),
918 impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> {
919 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
920 Self { instance: self.instance.fold_with(folder), promoted: self.promoted }
923 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
924 self.instance.visit_with(visitor)
928 impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
929 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
930 let kind = match *self.kind() {
931 ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)),
932 ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)),
933 ty::Slice(typ) => ty::Slice(typ.fold_with(folder)),
934 ty::Adt(tid, substs) => ty::Adt(tid, substs.fold_with(folder)),
935 ty::Dynamic(trait_ty, region) => {
936 ty::Dynamic(trait_ty.fold_with(folder), region.fold_with(folder))
938 ty::Tuple(ts) => ty::Tuple(ts.fold_with(folder)),
939 ty::FnDef(def_id, substs) => ty::FnDef(def_id, substs.fold_with(folder)),
940 ty::FnPtr(f) => ty::FnPtr(f.fold_with(folder)),
941 ty::Ref(r, ty, mutbl) => ty::Ref(r.fold_with(folder), ty.fold_with(folder), mutbl),
942 ty::Generator(did, substs, movability) => {
943 ty::Generator(did, substs.fold_with(folder), movability)
945 ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
946 ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
947 ty::Projection(data) => ty::Projection(data.fold_with(folder)),
948 ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)),
960 | ty::Placeholder(..)
962 | ty::Foreign(..) => return self,
965 if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) }
968 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
972 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
974 ty::RawPtr(ref tm) => tm.visit_with(visitor),
975 ty::Array(typ, sz) => {
976 typ.visit_with(visitor)?;
977 sz.visit_with(visitor)
979 ty::Slice(typ) => typ.visit_with(visitor),
980 ty::Adt(_, substs) => substs.visit_with(visitor),
981 ty::Dynamic(ref trait_ty, ref reg) => {
982 trait_ty.visit_with(visitor)?;
983 reg.visit_with(visitor)
985 ty::Tuple(ts) => ts.visit_with(visitor),
986 ty::FnDef(_, substs) => substs.visit_with(visitor),
987 ty::FnPtr(ref f) => f.visit_with(visitor),
988 ty::Ref(r, ty, _) => {
989 r.visit_with(visitor)?;
990 ty.visit_with(visitor)
992 ty::Generator(_did, ref substs, _) => substs.visit_with(visitor),
993 ty::GeneratorWitness(ref types) => types.visit_with(visitor),
994 ty::Closure(_did, ref substs) => substs.visit_with(visitor),
995 ty::Projection(ref data) => data.visit_with(visitor),
996 ty::Opaque(_, ref substs) => substs.visit_with(visitor),
1007 | ty::Placeholder(..)
1010 | ty::Foreign(..) => ControlFlow::CONTINUE,
1014 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1015 visitor.visit_ty(self)
1019 impl<'tcx> TypeFoldable<'tcx> for ty::Region<'tcx> {
1020 fn super_fold_with<F: TypeFolder<'tcx>>(self, _folder: &mut F) -> Self {
1024 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1025 folder.fold_region(self)
1028 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
1029 ControlFlow::CONTINUE
1032 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1033 visitor.visit_region(*self)
1037 impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
1038 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1039 let new = ty::PredicateKind::super_fold_with(self.inner.kind, folder);
1040 folder.tcx().reuse_or_mk_predicate(self, new)
1043 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1044 ty::PredicateKind::super_visit_with(&self.inner.kind, visitor)
1047 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1048 visitor.visit_predicate(*self)
1051 fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool {
1052 self.inner.outer_exclusive_binder > binder
1055 fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
1056 self.inner.flags.intersects(flags)
1060 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
1061 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1062 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_predicates(v))
1065 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1066 self.iter().try_for_each(|p| p.visit_with(visitor))
1070 impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec<I, T> {
1071 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1072 self.map_id(|x| x.fold_with(folder))
1075 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1076 self.iter().try_for_each(|t| t.visit_with(visitor))
1080 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> {
1081 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1082 let ty = self.ty.fold_with(folder);
1083 let val = self.val.fold_with(folder);
1084 if ty != self.ty || val != self.val {
1085 folder.tcx().mk_const(ty::Const { ty, val })
1091 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1092 folder.fold_const(self)
1095 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1096 self.ty.visit_with(visitor)?;
1097 self.val.visit_with(visitor)
1100 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1101 visitor.visit_const(self)
1105 impl<'tcx> TypeFoldable<'tcx> for ty::ConstKind<'tcx> {
1106 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1108 ty::ConstKind::Infer(ic) => ty::ConstKind::Infer(ic.fold_with(folder)),
1109 ty::ConstKind::Param(p) => ty::ConstKind::Param(p.fold_with(folder)),
1110 ty::ConstKind::Unevaluated(did, substs, promoted) => {
1111 ty::ConstKind::Unevaluated(did, substs.fold_with(folder), promoted)
1113 ty::ConstKind::Value(_)
1114 | ty::ConstKind::Bound(..)
1115 | ty::ConstKind::Placeholder(..)
1116 | ty::ConstKind::Error(_) => self,
1120 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1122 ty::ConstKind::Infer(ic) => ic.visit_with(visitor),
1123 ty::ConstKind::Param(p) => p.visit_with(visitor),
1124 ty::ConstKind::Unevaluated(_, substs, _) => substs.visit_with(visitor),
1125 ty::ConstKind::Value(_)
1126 | ty::ConstKind::Bound(..)
1127 | ty::ConstKind::Placeholder(_)
1128 | ty::ConstKind::Error(_) => ControlFlow::CONTINUE,
1133 impl<'tcx> TypeFoldable<'tcx> for InferConst<'tcx> {
1134 fn super_fold_with<F: TypeFolder<'tcx>>(self, _folder: &mut F) -> Self {
1138 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
1139 ControlFlow::CONTINUE