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::BoundRegionKind {
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),
239 impl fmt::Debug for ty::PredicateAtom<'tcx> {
240 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
242 ty::PredicateAtom::Trait(ref a, constness) => {
243 if let hir::Constness::Const = constness {
244 write!(f, "const ")?;
248 ty::PredicateAtom::Subtype(ref pair) => pair.fmt(f),
249 ty::PredicateAtom::RegionOutlives(ref pair) => pair.fmt(f),
250 ty::PredicateAtom::TypeOutlives(ref pair) => pair.fmt(f),
251 ty::PredicateAtom::Projection(ref pair) => pair.fmt(f),
252 ty::PredicateAtom::WellFormed(data) => write!(f, "WellFormed({:?})", data),
253 ty::PredicateAtom::ObjectSafe(trait_def_id) => {
254 write!(f, "ObjectSafe({:?})", trait_def_id)
256 ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
257 write!(f, "ClosureKind({:?}, {:?}, {:?})", closure_def_id, closure_substs, kind)
259 ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
260 write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)
262 ty::PredicateAtom::ConstEquate(c1, c2) => write!(f, "ConstEquate({:?}, {:?})", c1, c2),
263 ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
264 write!(f, "TypeWellFormedFromEnv({:?})", ty)
270 ///////////////////////////////////////////////////////////////////////////
273 // For things that don't carry any arena-allocated data (and are
274 // copy...), just add them to this list.
276 TrivialTypeFoldableAndLiftImpls! {
280 ::rustc_target::abi::VariantIdx,
284 crate::middle::region::Scope,
285 ::rustc_ast::FloatTy,
286 ::rustc_ast::InlineAsmOptions,
287 ::rustc_ast::InlineAsmTemplatePiece,
289 ::rustc_span::symbol::Symbol,
290 ::rustc_hir::def::Res,
291 ::rustc_hir::def_id::DefId,
292 ::rustc_hir::def_id::LocalDefId,
294 ::rustc_hir::LlvmInlineAsmInner,
295 ::rustc_hir::MatchSource,
296 ::rustc_hir::Mutability,
297 ::rustc_hir::Unsafety,
298 ::rustc_target::asm::InlineAsmRegOrRegClass,
299 ::rustc_target::spec::abi::Abi,
300 crate::mir::coverage::ExpressionOperandId,
301 crate::mir::coverage::CounterValueReference,
302 crate::mir::coverage::InjectedExpressionId,
303 crate::mir::coverage::InjectedExpressionIndex,
304 crate::mir::coverage::MappedExpressionIndex,
306 crate::mir::Promoted,
307 crate::traits::Reveal,
308 crate::ty::adjustment::AutoBorrowMutability,
310 // Including `BoundRegionKind` is a *bit* dubious, but direct
311 // references to bound region appear in `ty::Error`, and aren't
312 // really meant to be folded. In general, we can only fold a fully
314 crate::ty::BoundRegionKind,
315 crate::ty::AssocItem,
316 crate::ty::Placeholder<crate::ty::BoundRegionKind>,
317 crate::ty::ClosureKind,
318 crate::ty::FreeRegion,
320 crate::ty::IntVarValue,
321 crate::ty::ParamConst,
323 crate::ty::adjustment::PointerCast,
324 crate::ty::RegionVid,
325 crate::ty::UniverseIndex,
330 ///////////////////////////////////////////////////////////////////////////
331 // Lift implementations
333 // FIXME(eddyb) replace all the uses of `Option::map` with `?`.
334 impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) {
335 type Lifted = (A::Lifted, B::Lifted);
336 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
337 Some((tcx.lift(self.0)?, tcx.lift(self.1)?))
341 impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>, C: Lift<'tcx>> Lift<'tcx> for (A, B, C) {
342 type Lifted = (A::Lifted, B::Lifted, C::Lifted);
343 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
344 Some((tcx.lift(self.0)?, tcx.lift(self.1)?, tcx.lift(self.2)?))
348 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Option<T> {
349 type Lifted = Option<T::Lifted>;
350 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
352 Some(x) => tcx.lift(x).map(Some),
358 impl<'tcx, T: Lift<'tcx>, E: Lift<'tcx>> Lift<'tcx> for Result<T, E> {
359 type Lifted = Result<T::Lifted, E::Lifted>;
360 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
362 Ok(x) => tcx.lift(x).map(Ok),
363 Err(e) => tcx.lift(e).map(Err),
368 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Box<T> {
369 type Lifted = Box<T::Lifted>;
370 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
371 tcx.lift(*self).map(Box::new)
375 impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Rc<T> {
376 type Lifted = Rc<T::Lifted>;
377 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
378 tcx.lift(self.as_ref().clone()).map(Rc::new)
382 impl<'tcx, T: Lift<'tcx> + Clone> Lift<'tcx> for Arc<T> {
383 type Lifted = Arc<T::Lifted>;
384 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
385 tcx.lift(self.as_ref().clone()).map(Arc::new)
388 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec<T> {
389 type Lifted = Vec<T::Lifted>;
390 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
391 self.into_iter().map(|v| tcx.lift(v)).collect()
395 impl<'tcx, I: Idx, T: Lift<'tcx>> Lift<'tcx> for IndexVec<I, T> {
396 type Lifted = IndexVec<I, T::Lifted>;
397 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
398 self.into_iter().map(|e| tcx.lift(e)).collect()
402 impl<'a, 'tcx> Lift<'tcx> for ty::TraitRef<'a> {
403 type Lifted = ty::TraitRef<'tcx>;
404 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
405 tcx.lift(self.substs).map(|substs| ty::TraitRef { def_id: self.def_id, substs })
409 impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialTraitRef<'a> {
410 type Lifted = ty::ExistentialTraitRef<'tcx>;
411 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
412 tcx.lift(self.substs).map(|substs| ty::ExistentialTraitRef { def_id: self.def_id, substs })
416 impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialPredicate<'a> {
417 type Lifted = ty::ExistentialPredicate<'tcx>;
418 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
420 ty::ExistentialPredicate::Trait(x) => tcx.lift(x).map(ty::ExistentialPredicate::Trait),
421 ty::ExistentialPredicate::Projection(x) => {
422 tcx.lift(x).map(ty::ExistentialPredicate::Projection)
424 ty::ExistentialPredicate::AutoTrait(def_id) => {
425 Some(ty::ExistentialPredicate::AutoTrait(def_id))
431 impl<'a, 'tcx> Lift<'tcx> for ty::TraitPredicate<'a> {
432 type Lifted = ty::TraitPredicate<'tcx>;
433 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::TraitPredicate<'tcx>> {
434 tcx.lift(self.trait_ref).map(|trait_ref| ty::TraitPredicate { trait_ref })
438 impl<'a, 'tcx> Lift<'tcx> for ty::SubtypePredicate<'a> {
439 type Lifted = ty::SubtypePredicate<'tcx>;
440 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::SubtypePredicate<'tcx>> {
441 tcx.lift((self.a, self.b)).map(|(a, b)| ty::SubtypePredicate {
442 a_is_expected: self.a_is_expected,
449 impl<'tcx, A: Copy + Lift<'tcx>, B: Copy + Lift<'tcx>> Lift<'tcx> for ty::OutlivesPredicate<A, B> {
450 type Lifted = ty::OutlivesPredicate<A::Lifted, B::Lifted>;
451 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
452 tcx.lift((self.0, self.1)).map(|(a, b)| ty::OutlivesPredicate(a, b))
456 impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionTy<'a> {
457 type Lifted = ty::ProjectionTy<'tcx>;
458 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::ProjectionTy<'tcx>> {
459 tcx.lift(self.substs)
460 .map(|substs| ty::ProjectionTy { item_def_id: self.item_def_id, substs })
464 impl<'a, 'tcx> Lift<'tcx> for ty::ProjectionPredicate<'a> {
465 type Lifted = ty::ProjectionPredicate<'tcx>;
466 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<ty::ProjectionPredicate<'tcx>> {
467 tcx.lift((self.projection_ty, self.ty))
468 .map(|(projection_ty, ty)| ty::ProjectionPredicate { projection_ty, ty })
472 impl<'a, 'tcx> Lift<'tcx> for ty::ExistentialProjection<'a> {
473 type Lifted = ty::ExistentialProjection<'tcx>;
474 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
475 tcx.lift(self.substs).map(|substs| ty::ExistentialProjection {
477 ty: tcx.lift(self.ty).expect("type must lift when substs do"),
478 item_def_id: self.item_def_id,
483 impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
484 type Lifted = ty::PredicateKind<'tcx>;
485 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
487 ty::PredicateKind::ForAll(binder) => tcx.lift(binder).map(ty::PredicateKind::ForAll),
492 impl<'a, 'tcx> Lift<'tcx> for ty::PredicateAtom<'a> {
493 type Lifted = ty::PredicateAtom<'tcx>;
494 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
496 ty::PredicateAtom::Trait(data, constness) => {
497 tcx.lift(data).map(|data| ty::PredicateAtom::Trait(data, constness))
499 ty::PredicateAtom::Subtype(data) => tcx.lift(data).map(ty::PredicateAtom::Subtype),
500 ty::PredicateAtom::RegionOutlives(data) => {
501 tcx.lift(data).map(ty::PredicateAtom::RegionOutlives)
503 ty::PredicateAtom::TypeOutlives(data) => {
504 tcx.lift(data).map(ty::PredicateAtom::TypeOutlives)
506 ty::PredicateAtom::Projection(data) => {
507 tcx.lift(data).map(ty::PredicateAtom::Projection)
509 ty::PredicateAtom::WellFormed(ty) => tcx.lift(ty).map(ty::PredicateAtom::WellFormed),
510 ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind) => {
511 tcx.lift(closure_substs).map(|closure_substs| {
512 ty::PredicateAtom::ClosureKind(closure_def_id, closure_substs, kind)
515 ty::PredicateAtom::ObjectSafe(trait_def_id) => {
516 Some(ty::PredicateAtom::ObjectSafe(trait_def_id))
518 ty::PredicateAtom::ConstEvaluatable(def_id, substs) => {
519 tcx.lift(substs).map(|substs| ty::PredicateAtom::ConstEvaluatable(def_id, substs))
521 ty::PredicateAtom::ConstEquate(c1, c2) => {
522 tcx.lift((c1, c2)).map(|(c1, c2)| ty::PredicateAtom::ConstEquate(c1, c2))
524 ty::PredicateAtom::TypeWellFormedFromEnv(ty) => {
525 tcx.lift(ty).map(ty::PredicateAtom::TypeWellFormedFromEnv)
531 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
532 type Lifted = ty::Binder<T::Lifted>;
533 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
534 self.map_bound(|v| tcx.lift(v)).transpose()
538 impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> {
539 type Lifted = ty::ParamEnv<'tcx>;
540 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
541 tcx.lift(self.caller_bounds())
542 .map(|caller_bounds| ty::ParamEnv::new(caller_bounds, self.reveal()))
546 impl<'a, 'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::ParamEnvAnd<'a, T> {
547 type Lifted = ty::ParamEnvAnd<'tcx, T::Lifted>;
548 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
549 tcx.lift(self.param_env).and_then(|param_env| {
550 tcx.lift(self.value).map(|value| ty::ParamEnvAnd { param_env, value })
555 impl<'a, 'tcx> Lift<'tcx> for ty::ClosureSubsts<'a> {
556 type Lifted = ty::ClosureSubsts<'tcx>;
557 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
558 tcx.lift(self.substs).map(|substs| ty::ClosureSubsts { substs })
562 impl<'a, 'tcx> Lift<'tcx> for ty::GeneratorSubsts<'a> {
563 type Lifted = ty::GeneratorSubsts<'tcx>;
564 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
565 tcx.lift(self.substs).map(|substs| ty::GeneratorSubsts { substs })
569 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjustment<'a> {
570 type Lifted = ty::adjustment::Adjustment<'tcx>;
571 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
572 let ty::adjustment::Adjustment { kind, target } = self;
573 tcx.lift(kind).and_then(|kind| {
574 tcx.lift(target).map(|target| ty::adjustment::Adjustment { kind, target })
579 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::Adjust<'a> {
580 type Lifted = ty::adjustment::Adjust<'tcx>;
581 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
583 ty::adjustment::Adjust::NeverToAny => Some(ty::adjustment::Adjust::NeverToAny),
584 ty::adjustment::Adjust::Pointer(ptr) => Some(ty::adjustment::Adjust::Pointer(ptr)),
585 ty::adjustment::Adjust::Deref(overloaded) => {
586 tcx.lift(overloaded).map(ty::adjustment::Adjust::Deref)
588 ty::adjustment::Adjust::Borrow(autoref) => {
589 tcx.lift(autoref).map(ty::adjustment::Adjust::Borrow)
595 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::OverloadedDeref<'a> {
596 type Lifted = ty::adjustment::OverloadedDeref<'tcx>;
597 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
598 tcx.lift(self.region).map(|region| ty::adjustment::OverloadedDeref {
606 impl<'a, 'tcx> Lift<'tcx> for ty::adjustment::AutoBorrow<'a> {
607 type Lifted = ty::adjustment::AutoBorrow<'tcx>;
608 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
610 ty::adjustment::AutoBorrow::Ref(r, m) => {
611 tcx.lift(r).map(|r| ty::adjustment::AutoBorrow::Ref(r, m))
613 ty::adjustment::AutoBorrow::RawPtr(m) => Some(ty::adjustment::AutoBorrow::RawPtr(m)),
618 impl<'a, 'tcx> Lift<'tcx> for ty::GenSig<'a> {
619 type Lifted = ty::GenSig<'tcx>;
620 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
621 tcx.lift((self.resume_ty, self.yield_ty, self.return_ty))
622 .map(|(resume_ty, yield_ty, return_ty)| ty::GenSig { resume_ty, yield_ty, return_ty })
626 impl<'a, 'tcx> Lift<'tcx> for ty::FnSig<'a> {
627 type Lifted = ty::FnSig<'tcx>;
628 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
629 tcx.lift(self.inputs_and_output).map(|x| ty::FnSig {
630 inputs_and_output: x,
631 c_variadic: self.c_variadic,
632 unsafety: self.unsafety,
638 impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::error::ExpectedFound<T> {
639 type Lifted = ty::error::ExpectedFound<T::Lifted>;
640 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
641 let ty::error::ExpectedFound { expected, found } = self;
642 tcx.lift(expected).and_then(|expected| {
643 tcx.lift(found).map(|found| ty::error::ExpectedFound { expected, found })
648 impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> {
649 type Lifted = ty::error::TypeError<'tcx>;
650 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
651 use crate::ty::error::TypeError::*;
654 Mismatch => Mismatch,
655 UnsafetyMismatch(x) => UnsafetyMismatch(x),
656 AbiMismatch(x) => AbiMismatch(x),
657 Mutability => Mutability,
658 TupleSize(x) => TupleSize(x),
659 FixedArraySize(x) => FixedArraySize(x),
660 ArgCount => ArgCount,
661 RegionsDoesNotOutlive(a, b) => {
662 return tcx.lift((a, b)).map(|(a, b)| RegionsDoesNotOutlive(a, b));
664 RegionsInsufficientlyPolymorphic(a, b) => {
665 return tcx.lift(b).map(|b| RegionsInsufficientlyPolymorphic(a, b));
667 RegionsOverlyPolymorphic(a, b) => {
668 return tcx.lift(b).map(|b| RegionsOverlyPolymorphic(a, b));
670 RegionsPlaceholderMismatch => RegionsPlaceholderMismatch,
671 IntMismatch(x) => IntMismatch(x),
672 FloatMismatch(x) => FloatMismatch(x),
673 Traits(x) => Traits(x),
674 VariadicMismatch(x) => VariadicMismatch(x),
675 CyclicTy(t) => return tcx.lift(t).map(|t| CyclicTy(t)),
676 CyclicConst(ct) => return tcx.lift(ct).map(|ct| CyclicConst(ct)),
677 ProjectionMismatched(x) => ProjectionMismatched(x),
678 Sorts(x) => return tcx.lift(x).map(Sorts),
679 ExistentialMismatch(x) => return tcx.lift(x).map(ExistentialMismatch),
680 ConstMismatch(x) => return tcx.lift(x).map(ConstMismatch),
681 IntrinsicCast => IntrinsicCast,
682 TargetFeatureCast(x) => TargetFeatureCast(x),
683 ObjectUnsafeCoercion(x) => return tcx.lift(x).map(ObjectUnsafeCoercion),
688 impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
689 type Lifted = ty::InstanceDef<'tcx>;
690 fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
692 ty::InstanceDef::Item(def_id) => Some(ty::InstanceDef::Item(def_id)),
693 ty::InstanceDef::VtableShim(def_id) => Some(ty::InstanceDef::VtableShim(def_id)),
694 ty::InstanceDef::ReifyShim(def_id) => Some(ty::InstanceDef::ReifyShim(def_id)),
695 ty::InstanceDef::Intrinsic(def_id) => Some(ty::InstanceDef::Intrinsic(def_id)),
696 ty::InstanceDef::FnPtrShim(def_id, ty) => {
697 Some(ty::InstanceDef::FnPtrShim(def_id, tcx.lift(ty)?))
699 ty::InstanceDef::Virtual(def_id, n) => Some(ty::InstanceDef::Virtual(def_id, n)),
700 ty::InstanceDef::ClosureOnceShim { call_once } => {
701 Some(ty::InstanceDef::ClosureOnceShim { call_once })
703 ty::InstanceDef::DropGlue(def_id, ty) => {
704 Some(ty::InstanceDef::DropGlue(def_id, tcx.lift(ty)?))
706 ty::InstanceDef::CloneShim(def_id, ty) => {
707 Some(ty::InstanceDef::CloneShim(def_id, tcx.lift(ty)?))
713 ///////////////////////////////////////////////////////////////////////////
714 // TypeFoldable implementations.
716 // Ideally, each type should invoke `folder.fold_foo(self)` and
717 // nothing else. In some cases, though, we haven't gotten around to
718 // adding methods on the `folder` yet, and thus the folding is
719 // hard-coded here. This is less-flexible, because folders cannot
720 // override the behavior, but there are a lot of random types and one
721 // can easily refactor the folding into the TypeFolder trait as
724 /// AdtDefs are basically the same as a DefId.
725 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::AdtDef {
726 fn super_fold_with<F: TypeFolder<'tcx>>(self, _folder: &mut F) -> Self {
730 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
731 ControlFlow::CONTINUE
735 impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
736 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> (T, U) {
737 (self.0.fold_with(folder), self.1.fold_with(folder))
740 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
741 self.0.visit_with(visitor)?;
742 self.1.visit_with(visitor)
746 impl<'tcx, A: TypeFoldable<'tcx>, B: TypeFoldable<'tcx>, C: TypeFoldable<'tcx>> TypeFoldable<'tcx>
749 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> (A, B, C) {
750 (self.0.fold_with(folder), self.1.fold_with(folder), self.2.fold_with(folder))
753 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
754 self.0.visit_with(visitor)?;
755 self.1.visit_with(visitor)?;
756 self.2.visit_with(visitor)
760 EnumTypeFoldableImpl! {
761 impl<'tcx, T> TypeFoldable<'tcx> for Option<T> {
764 } where T: TypeFoldable<'tcx>
767 EnumTypeFoldableImpl! {
768 impl<'tcx, T, E> TypeFoldable<'tcx> for Result<T, E> {
771 } where T: TypeFoldable<'tcx>, E: TypeFoldable<'tcx>,
774 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc<T> {
775 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
776 // FIXME: Reuse the `Rc` here.
777 Rc::new((*self).clone().fold_with(folder))
780 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
781 (**self).visit_with(visitor)
785 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Arc<T> {
786 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
787 // FIXME: Reuse the `Arc` here.
788 Arc::new((*self).clone().fold_with(folder))
791 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
792 (**self).visit_with(visitor)
796 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<T> {
797 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
798 self.map_id(|value| value.fold_with(folder))
801 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
802 (**self).visit_with(visitor)
806 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec<T> {
807 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
808 self.map_id(|t| t.fold_with(folder))
811 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
812 self.iter().try_for_each(|t| t.visit_with(visitor))
816 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> {
817 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
818 self.map_id(|t| t.fold_with(folder))
821 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
822 self.iter().try_for_each(|t| t.visit_with(visitor))
826 impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
827 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
828 self.map_bound(|ty| ty.fold_with(folder))
831 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
832 folder.fold_binder(self)
835 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
836 self.as_ref().skip_binder().visit_with(visitor)
839 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
840 visitor.visit_binder(self)
844 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>> {
845 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
846 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v))
849 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
850 self.iter().try_for_each(|p| p.visit_with(visitor))
854 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
855 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
856 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_type_list(v))
859 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
860 self.iter().try_for_each(|t| t.visit_with(visitor))
864 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ProjectionKind> {
865 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
866 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v))
869 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
870 self.iter().try_for_each(|t| t.visit_with(visitor))
874 impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
875 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
876 use crate::ty::InstanceDef::*;
878 substs: self.substs.fold_with(folder),
879 def: match self.def {
880 Item(def) => Item(def.fold_with(folder)),
881 VtableShim(did) => VtableShim(did.fold_with(folder)),
882 ReifyShim(did) => ReifyShim(did.fold_with(folder)),
883 Intrinsic(did) => Intrinsic(did.fold_with(folder)),
884 FnPtrShim(did, ty) => FnPtrShim(did.fold_with(folder), ty.fold_with(folder)),
885 Virtual(did, i) => Virtual(did.fold_with(folder), i),
886 ClosureOnceShim { call_once } => {
887 ClosureOnceShim { call_once: call_once.fold_with(folder) }
889 DropGlue(did, ty) => DropGlue(did.fold_with(folder), ty.fold_with(folder)),
890 CloneShim(did, ty) => CloneShim(did.fold_with(folder), ty.fold_with(folder)),
895 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
896 use crate::ty::InstanceDef::*;
897 self.substs.visit_with(visitor)?;
899 Item(def) => def.visit_with(visitor),
900 VtableShim(did) | ReifyShim(did) | Intrinsic(did) | Virtual(did, _) => {
901 did.visit_with(visitor)
903 FnPtrShim(did, ty) | CloneShim(did, ty) => {
904 did.visit_with(visitor)?;
905 ty.visit_with(visitor)
907 DropGlue(did, ty) => {
908 did.visit_with(visitor)?;
909 ty.visit_with(visitor)
911 ClosureOnceShim { call_once } => call_once.visit_with(visitor),
916 impl<'tcx> TypeFoldable<'tcx> for interpret::GlobalId<'tcx> {
917 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
918 Self { instance: self.instance.fold_with(folder), promoted: self.promoted }
921 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
922 self.instance.visit_with(visitor)
926 impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
927 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
928 let kind = match *self.kind() {
929 ty::RawPtr(tm) => ty::RawPtr(tm.fold_with(folder)),
930 ty::Array(typ, sz) => ty::Array(typ.fold_with(folder), sz.fold_with(folder)),
931 ty::Slice(typ) => ty::Slice(typ.fold_with(folder)),
932 ty::Adt(tid, substs) => ty::Adt(tid, substs.fold_with(folder)),
933 ty::Dynamic(trait_ty, region) => {
934 ty::Dynamic(trait_ty.fold_with(folder), region.fold_with(folder))
936 ty::Tuple(ts) => ty::Tuple(ts.fold_with(folder)),
937 ty::FnDef(def_id, substs) => ty::FnDef(def_id, substs.fold_with(folder)),
938 ty::FnPtr(f) => ty::FnPtr(f.fold_with(folder)),
939 ty::Ref(r, ty, mutbl) => ty::Ref(r.fold_with(folder), ty.fold_with(folder), mutbl),
940 ty::Generator(did, substs, movability) => {
941 ty::Generator(did, substs.fold_with(folder), movability)
943 ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
944 ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
945 ty::Projection(data) => ty::Projection(data.fold_with(folder)),
946 ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)),
958 | ty::Placeholder(..)
960 | ty::Foreign(..) => return self,
963 if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) }
966 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
970 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
972 ty::RawPtr(ref tm) => tm.visit_with(visitor),
973 ty::Array(typ, sz) => {
974 typ.visit_with(visitor)?;
975 sz.visit_with(visitor)
977 ty::Slice(typ) => typ.visit_with(visitor),
978 ty::Adt(_, substs) => substs.visit_with(visitor),
979 ty::Dynamic(ref trait_ty, ref reg) => {
980 trait_ty.visit_with(visitor)?;
981 reg.visit_with(visitor)
983 ty::Tuple(ts) => ts.visit_with(visitor),
984 ty::FnDef(_, substs) => substs.visit_with(visitor),
985 ty::FnPtr(ref f) => f.visit_with(visitor),
986 ty::Ref(r, ty, _) => {
987 r.visit_with(visitor)?;
988 ty.visit_with(visitor)
990 ty::Generator(_did, ref substs, _) => substs.visit_with(visitor),
991 ty::GeneratorWitness(ref types) => types.visit_with(visitor),
992 ty::Closure(_did, ref substs) => substs.visit_with(visitor),
993 ty::Projection(ref data) => data.visit_with(visitor),
994 ty::Opaque(_, ref substs) => substs.visit_with(visitor),
1005 | ty::Placeholder(..)
1008 | ty::Foreign(..) => ControlFlow::CONTINUE,
1012 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1013 visitor.visit_ty(self)
1017 impl<'tcx> TypeFoldable<'tcx> for ty::Region<'tcx> {
1018 fn super_fold_with<F: TypeFolder<'tcx>>(self, _folder: &mut F) -> Self {
1022 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1023 folder.fold_region(self)
1026 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
1027 ControlFlow::CONTINUE
1030 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1031 visitor.visit_region(*self)
1035 impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> {
1036 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1037 let new = ty::PredicateKind::super_fold_with(self.inner.kind, folder);
1038 folder.tcx().reuse_or_mk_predicate(self, new)
1041 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1042 ty::PredicateKind::super_visit_with(&self.inner.kind, visitor)
1045 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1046 visitor.visit_predicate(*self)
1049 fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool {
1050 self.inner.outer_exclusive_binder > binder
1053 fn has_type_flags(&self, flags: ty::TypeFlags) -> bool {
1054 self.inner.flags.intersects(flags)
1058 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Predicate<'tcx>> {
1059 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1060 ty::util::fold_list(self, folder, |tcx, v| tcx.intern_predicates(v))
1063 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1064 self.iter().try_for_each(|p| p.visit_with(visitor))
1068 impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec<I, T> {
1069 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1070 self.map_id(|x| x.fold_with(folder))
1073 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1074 self.iter().try_for_each(|t| t.visit_with(visitor))
1078 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> {
1079 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1080 let ty = self.ty.fold_with(folder);
1081 let val = self.val.fold_with(folder);
1082 if ty != self.ty || val != self.val {
1083 folder.tcx().mk_const(ty::Const { ty, val })
1089 fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1090 folder.fold_const(self)
1093 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1094 self.ty.visit_with(visitor)?;
1095 self.val.visit_with(visitor)
1098 fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1099 visitor.visit_const(self)
1103 impl<'tcx> TypeFoldable<'tcx> for ty::ConstKind<'tcx> {
1104 fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
1106 ty::ConstKind::Infer(ic) => ty::ConstKind::Infer(ic.fold_with(folder)),
1107 ty::ConstKind::Param(p) => ty::ConstKind::Param(p.fold_with(folder)),
1108 ty::ConstKind::Unevaluated(did, substs, promoted) => {
1109 ty::ConstKind::Unevaluated(did, substs.fold_with(folder), promoted)
1111 ty::ConstKind::Value(_)
1112 | ty::ConstKind::Bound(..)
1113 | ty::ConstKind::Placeholder(..)
1114 | ty::ConstKind::Error(_) => self,
1118 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
1120 ty::ConstKind::Infer(ic) => ic.visit_with(visitor),
1121 ty::ConstKind::Param(p) => p.visit_with(visitor),
1122 ty::ConstKind::Unevaluated(_, substs, _) => substs.visit_with(visitor),
1123 ty::ConstKind::Value(_)
1124 | ty::ConstKind::Bound(..)
1125 | ty::ConstKind::Placeholder(_)
1126 | ty::ConstKind::Error(_) => ControlFlow::CONTINUE,
1131 impl<'tcx> TypeFoldable<'tcx> for InferConst<'tcx> {
1132 fn super_fold_with<F: TypeFolder<'tcx>>(self, _folder: &mut F) -> Self {
1136 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
1137 ControlFlow::CONTINUE