1 // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use smallvec::SmallVec;
14 use traits::project::Normalized;
15 use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
16 use ty::{self, Lift, TyCtxt};
21 // structural impls for the structs in traits
23 impl<'tcx, T: fmt::Debug> fmt::Debug for Normalized<'tcx, T> {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 write!(f, "Normalized({:?},{:?})", self.value, self.obligations)
29 impl<'tcx, O: fmt::Debug> fmt::Debug for traits::Obligation<'tcx, O> {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 if ty::tls::with(|tcx| tcx.sess.verbose()) {
34 "Obligation(predicate={:?},cause={:?},depth={})",
35 self.predicate, self.cause, self.recursion_depth
40 "Obligation(predicate={:?},depth={})",
41 self.predicate, self.recursion_depth
47 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::Vtable<'tcx, N> {
48 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50 super::VtableImpl(ref v) => write!(f, "{:?}", v),
52 super::VtableAutoImpl(ref t) => write!(f, "{:?}", t),
54 super::VtableClosure(ref d) => write!(f, "{:?}", d),
56 super::VtableGenerator(ref d) => write!(f, "{:?}", d),
58 super::VtableFnPointer(ref d) => write!(f, "VtableFnPointer({:?})", d),
60 super::VtableObject(ref d) => write!(f, "{:?}", d),
62 super::VtableParam(ref n) => write!(f, "VtableParam({:?})", n),
64 super::VtableBuiltin(ref d) => write!(f, "{:?}", d),
69 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableImplData<'tcx, N> {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
73 "VtableImpl(impl_def_id={:?}, substs={:?}, nested={:?})",
74 self.impl_def_id, self.substs, self.nested
79 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableGeneratorData<'tcx, N> {
80 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
83 "VtableGenerator(generator_def_id={:?}, substs={:?}, nested={:?})",
84 self.generator_def_id, self.substs, self.nested
89 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> {
90 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
93 "VtableClosure(closure_def_id={:?}, substs={:?}, nested={:?})",
94 self.closure_def_id, self.substs, self.nested
99 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
100 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
101 write!(f, "VtableBuiltin(nested={:?})", self.nested)
105 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableAutoImplData<N> {
106 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
109 "VtableAutoImplData(trait_def_id={:?}, nested={:?})",
110 self.trait_def_id, self.nested
115 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableObjectData<'tcx, N> {
116 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
119 "VtableObject(upcast={:?}, vtable_base={}, nested={:?})",
120 self.upcast_trait_ref, self.vtable_base, self.nested
125 impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableFnPointerData<'tcx, N> {
126 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
129 "VtableFnPointer(fn_ty={:?}, nested={:?})",
130 self.fn_ty, self.nested
135 impl<'tcx> fmt::Debug for traits::FulfillmentError<'tcx> {
136 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
137 write!(f, "FulfillmentError({:?},{:?})", self.obligation, self.code)
141 impl<'tcx> fmt::Debug for traits::FulfillmentErrorCode<'tcx> {
142 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
144 super::CodeSelectionError(ref e) => write!(f, "{:?}", e),
145 super::CodeProjectionError(ref e) => write!(f, "{:?}", e),
146 super::CodeSubtypeError(ref a, ref b) => {
147 write!(f, "CodeSubtypeError({:?}, {:?})", a, b)
149 super::CodeAmbiguity => write!(f, "Ambiguity"),
154 impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
155 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
156 write!(f, "MismatchedProjectionTypes({:?})", self.err)
160 ///////////////////////////////////////////////////////////////////////////
161 // Lift implementations
163 impl<'a, 'tcx> Lift<'tcx> for traits::SelectionError<'a> {
164 type Lifted = traits::SelectionError<'tcx>;
165 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
167 super::Unimplemented => Some(super::Unimplemented),
168 super::OutputTypeParameterMismatch(a, b, ref err) => {
169 tcx.lift(&(a, b)).and_then(|(a, b)|
171 .map(|err| super::OutputTypeParameterMismatch(a, b, err))
174 super::TraitNotObjectSafe(def_id) => Some(super::TraitNotObjectSafe(def_id)),
175 super::ConstEvalFailure(ref err) => tcx.lift(&**err).map(|err| super::ConstEvalFailure(
178 super::Overflow => Some(super::Overflow),
183 impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
184 type Lifted = traits::ObligationCauseCode<'tcx>;
185 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
187 super::ReturnNoExpression => Some(super::ReturnNoExpression),
188 super::MiscObligation => Some(super::MiscObligation),
189 super::SliceOrArrayElem => Some(super::SliceOrArrayElem),
190 super::TupleElem => Some(super::TupleElem),
191 super::ProjectionWf(proj) => tcx.lift(&proj).map(super::ProjectionWf),
192 super::ItemObligation(def_id) => Some(super::ItemObligation(def_id)),
193 super::ReferenceOutlivesReferent(ty) => {
194 tcx.lift(&ty).map(super::ReferenceOutlivesReferent)
196 super::ObjectTypeBound(ty, r) => tcx.lift(&ty).and_then(|ty|
198 .and_then(|r| Some(super::ObjectTypeBound(ty, r)))
200 super::ObjectCastObligation(ty) => tcx.lift(&ty).map(super::ObjectCastObligation),
201 super::AssignmentLhsSized => Some(super::AssignmentLhsSized),
202 super::TupleInitializerSized => Some(super::TupleInitializerSized),
203 super::StructInitializerSized => Some(super::StructInitializerSized),
204 super::VariableType(id) => Some(super::VariableType(id)),
205 super::ReturnType(id) => Some(super::ReturnType(id)),
206 super::SizedArgumentType => Some(super::SizedArgumentType),
207 super::SizedReturnType => Some(super::SizedReturnType),
208 super::SizedYieldType => Some(super::SizedYieldType),
209 super::RepeatVec => Some(super::RepeatVec),
210 super::FieldSized { adt_kind, last } => Some(super::FieldSized { adt_kind, last }),
211 super::ConstSized => Some(super::ConstSized),
212 super::SharedStatic => Some(super::SharedStatic),
213 super::BuiltinDerivedObligation(ref cause) => {
214 tcx.lift(cause).map(super::BuiltinDerivedObligation)
216 super::ImplDerivedObligation(ref cause) => {
217 tcx.lift(cause).map(super::ImplDerivedObligation)
219 super::CompareImplMethodObligation {
223 } => Some(super::CompareImplMethodObligation {
228 super::ExprAssignable => Some(super::ExprAssignable),
229 super::MatchExpressionArm { arm_span, source } => Some(super::MatchExpressionArm {
233 super::IfExpression => Some(super::IfExpression),
234 super::IfExpressionWithNoElse => Some(super::IfExpressionWithNoElse),
235 super::MainFunctionType => Some(super::MainFunctionType),
236 super::StartFunctionType => Some(super::StartFunctionType),
237 super::IntrinsicType => Some(super::IntrinsicType),
238 super::MethodReceiver => Some(super::MethodReceiver),
239 super::BlockTailExpression(id) => Some(super::BlockTailExpression(id)),
240 super::TrivialBound => Some(super::TrivialBound),
245 impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> {
246 type Lifted = traits::DerivedObligationCause<'tcx>;
247 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
248 tcx.lift(&self.parent_trait_ref).and_then(|trait_ref|
249 tcx.lift(&*self.parent_code)
250 .map(|code| traits::DerivedObligationCause {
251 parent_trait_ref: trait_ref,
252 parent_code: Rc::new(code),
258 impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCause<'a> {
259 type Lifted = traits::ObligationCause<'tcx>;
260 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
261 tcx.lift(&self.code).map(|code| traits::ObligationCause {
263 body_id: self.body_id,
270 impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
271 type Lifted = traits::Vtable<'tcx, ()>;
272 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
274 traits::VtableImpl(traits::VtableImplData {
278 }) => tcx.lift(&substs).map(|substs|
279 traits::VtableImpl(traits::VtableImplData {
285 traits::VtableAutoImpl(t) => Some(traits::VtableAutoImpl(t)),
286 traits::VtableGenerator(traits::VtableGeneratorData {
290 }) => tcx.lift(&substs).map(|substs|
291 traits::VtableGenerator(traits::VtableGeneratorData {
292 generator_def_id: generator_def_id,
297 traits::VtableClosure(traits::VtableClosureData {
301 }) => tcx.lift(&substs).map(|substs|
302 traits::VtableClosure(traits::VtableClosureData {
308 traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested }) => {
309 tcx.lift(&fn_ty).map(|fn_ty|
310 traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested })
313 traits::VtableParam(n) => Some(traits::VtableParam(n)),
314 traits::VtableBuiltin(n) => Some(traits::VtableBuiltin(n)),
315 traits::VtableObject(traits::VtableObjectData {
319 }) => tcx.lift(&upcast_trait_ref).map(|trait_ref|
320 traits::VtableObject(traits::VtableObjectData {
321 upcast_trait_ref: trait_ref,
330 ///////////////////////////////////////////////////////////////////////////
331 // TypeFoldable implementations.
333 impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
334 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
336 cause: self.cause.clone(),
337 recursion_depth: self.recursion_depth,
338 predicate: self.predicate.fold_with(folder),
339 param_env: self.param_env.fold_with(folder),
343 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
344 self.predicate.visit_with(visitor)
348 BraceStructTypeFoldableImpl! {
349 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableImplData<'tcx, N> {
350 impl_def_id, substs, nested
351 } where N: TypeFoldable<'tcx>
354 BraceStructTypeFoldableImpl! {
355 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableGeneratorData<'tcx, N> {
356 generator_def_id, substs, nested
357 } where N: TypeFoldable<'tcx>
360 BraceStructTypeFoldableImpl! {
361 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableClosureData<'tcx, N> {
362 closure_def_id, substs, nested
363 } where N: TypeFoldable<'tcx>
366 BraceStructTypeFoldableImpl! {
367 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableAutoImplData<N> {
369 } where N: TypeFoldable<'tcx>
372 BraceStructTypeFoldableImpl! {
373 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
375 } where N: TypeFoldable<'tcx>
378 BraceStructTypeFoldableImpl! {
379 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableObjectData<'tcx, N> {
380 upcast_trait_ref, vtable_base, nested
381 } where N: TypeFoldable<'tcx>
384 BraceStructTypeFoldableImpl! {
385 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableFnPointerData<'tcx, N> {
388 } where N: TypeFoldable<'tcx>
391 EnumTypeFoldableImpl! {
392 impl<'tcx, N> TypeFoldable<'tcx> for traits::Vtable<'tcx, N> {
393 (traits::VtableImpl)(a),
394 (traits::VtableAutoImpl)(a),
395 (traits::VtableGenerator)(a),
396 (traits::VtableClosure)(a),
397 (traits::VtableFnPointer)(a),
398 (traits::VtableParam)(a),
399 (traits::VtableBuiltin)(a),
400 (traits::VtableObject)(a),
401 } where N: TypeFoldable<'tcx>
404 BraceStructTypeFoldableImpl! {
405 impl<'tcx, T> TypeFoldable<'tcx> for Normalized<'tcx, T> {
408 } where T: TypeFoldable<'tcx>
411 impl<'tcx> fmt::Display for traits::WhereClause<'tcx> {
412 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
413 use traits::WhereClause::*;
416 Implemented(trait_ref) => write!(fmt, "Implemented({})", trait_ref),
417 ProjectionEq(projection) => write!(fmt, "ProjectionEq({})", projection),
418 RegionOutlives(predicate) => write!(fmt, "RegionOutlives({})", predicate),
419 TypeOutlives(predicate) => write!(fmt, "TypeOutlives({})", predicate),
424 impl<'tcx> fmt::Display for traits::WellFormed<'tcx> {
425 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
426 use traits::WellFormed::*;
429 Trait(trait_ref) => write!(fmt, "WellFormed({})", trait_ref),
430 Ty(ty) => write!(fmt, "WellFormed({})", ty),
435 impl<'tcx> fmt::Display for traits::FromEnv<'tcx> {
436 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
437 use traits::FromEnv::*;
440 Trait(trait_ref) => write!(fmt, "FromEnv({})", trait_ref),
441 Ty(ty) => write!(fmt, "FromEnv({})", ty),
446 impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> {
447 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
448 use traits::DomainGoal::*;
451 Holds(wc) => write!(fmt, "{}", wc),
452 WellFormed(wf) => write!(fmt, "{}", wf),
453 FromEnv(from_env) => write!(fmt, "{}", from_env),
454 Normalize(projection) => write!(fmt, "Normalize({})", projection),
459 impl fmt::Display for traits::QuantifierKind {
460 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
461 use traits::QuantifierKind::*;
464 Universal => write!(fmt, "forall"),
465 Existential => write!(fmt, "exists"),
470 impl<'tcx> fmt::Display for traits::Goal<'tcx> {
471 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
475 Implies(hypotheses, goal) => {
476 write!(fmt, "if (")?;
477 for (index, hyp) in hypotheses.iter().enumerate() {
481 write!(fmt, "{}", hyp)?;
483 write!(fmt, ") {{ {} }}", goal)
485 And(goal1, goal2) => write!(fmt, "({} && {})", goal1, goal2),
486 Not(goal) => write!(fmt, "not {{ {} }}", goal),
487 DomainGoal(goal) => write!(fmt, "{}", goal),
488 Quantified(qkind, goal) => {
489 // FIXME: appropriate binder names
490 write!(fmt, "{}<> {{ {} }}", qkind, goal.skip_binder())
492 CannotProve => write!(fmt, "CannotProve"),
497 impl<'tcx> fmt::Display for traits::ProgramClause<'tcx> {
498 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
499 let traits::ProgramClause { goal, hypotheses } = self;
500 write!(fmt, "{}", goal)?;
501 if !hypotheses.is_empty() {
502 write!(fmt, " :- ")?;
503 for (index, condition) in hypotheses.iter().enumerate() {
507 write!(fmt, "{}", condition)?;
514 impl<'tcx> fmt::Display for traits::Clause<'tcx> {
515 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
516 use traits::Clause::*;
519 Implies(clause) => write!(fmt, "{}", clause),
521 // FIXME: appropriate binder names
522 write!(fmt, "forall<> {{ {} }}", clause.skip_binder())
528 EnumTypeFoldableImpl! {
529 impl<'tcx> TypeFoldable<'tcx> for traits::WhereClause<'tcx> {
530 (traits::WhereClause::Implemented)(trait_ref),
531 (traits::WhereClause::ProjectionEq)(projection),
532 (traits::WhereClause::TypeOutlives)(ty_outlives),
533 (traits::WhereClause::RegionOutlives)(region_outlives),
538 impl<'a, 'tcx> Lift<'tcx> for traits::WhereClause<'a> {
539 type Lifted = traits::WhereClause<'tcx>;
540 (traits::WhereClause::Implemented)(trait_ref),
541 (traits::WhereClause::ProjectionEq)(projection),
542 (traits::WhereClause::TypeOutlives)(ty_outlives),
543 (traits::WhereClause::RegionOutlives)(region_outlives),
547 EnumTypeFoldableImpl! {
548 impl<'tcx> TypeFoldable<'tcx> for traits::WellFormed<'tcx> {
549 (traits::WellFormed::Trait)(trait_ref),
550 (traits::WellFormed::Ty)(ty),
555 impl<'a, 'tcx> Lift<'tcx> for traits::WellFormed<'a> {
556 type Lifted = traits::WellFormed<'tcx>;
557 (traits::WellFormed::Trait)(trait_ref),
558 (traits::WellFormed::Ty)(ty),
562 EnumTypeFoldableImpl! {
563 impl<'tcx> TypeFoldable<'tcx> for traits::FromEnv<'tcx> {
564 (traits::FromEnv::Trait)(trait_ref),
565 (traits::FromEnv::Ty)(ty),
570 impl<'a, 'tcx> Lift<'tcx> for traits::FromEnv<'a> {
571 type Lifted = traits::FromEnv<'tcx>;
572 (traits::FromEnv::Trait)(trait_ref),
573 (traits::FromEnv::Ty)(ty),
577 EnumTypeFoldableImpl! {
578 impl<'tcx> TypeFoldable<'tcx> for traits::DomainGoal<'tcx> {
579 (traits::DomainGoal::Holds)(wc),
580 (traits::DomainGoal::WellFormed)(wf),
581 (traits::DomainGoal::FromEnv)(from_env),
582 (traits::DomainGoal::Normalize)(projection),
587 impl<'a, 'tcx> Lift<'tcx> for traits::DomainGoal<'a> {
588 type Lifted = traits::DomainGoal<'tcx>;
589 (traits::DomainGoal::Holds)(wc),
590 (traits::DomainGoal::WellFormed)(wf),
591 (traits::DomainGoal::FromEnv)(from_env),
592 (traits::DomainGoal::Normalize)(projection),
596 CloneTypeFoldableAndLiftImpls! {
597 traits::QuantifierKind,
600 EnumTypeFoldableImpl! {
601 impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> {
602 (traits::Goal::Implies)(hypotheses, goal),
603 (traits::Goal::And)(goal1, goal2),
604 (traits::Goal::Not)(goal),
605 (traits::Goal::DomainGoal)(domain_goal),
606 (traits::Goal::Quantified)(qkind, goal),
607 (traits::Goal::CannotProve),
612 impl<'a, 'tcx> Lift<'tcx> for traits::Goal<'a> {
613 type Lifted = traits::Goal<'tcx>;
614 (traits::Goal::Implies)(hypotheses, goal),
615 (traits::Goal::And)(goal1, goal2),
616 (traits::Goal::Not)(goal),
617 (traits::Goal::DomainGoal)(domain_goal),
618 (traits::Goal::Quantified)(kind, goal),
619 (traits::Goal::CannotProve),
623 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<traits::Goal<'tcx>> {
624 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
626 .map(|t| t.fold_with(folder))
627 .collect::<SmallVec<[_; 8]>>();
628 folder.tcx().intern_goals(&v)
631 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
632 self.iter().any(|t| t.visit_with(visitor))
636 impl<'tcx> TypeFoldable<'tcx> for &'tcx traits::Goal<'tcx> {
637 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
638 let v = (**self).fold_with(folder);
639 folder.tcx().mk_goal(v)
642 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
643 (**self).visit_with(visitor)
647 BraceStructTypeFoldableImpl! {
648 impl<'tcx> TypeFoldable<'tcx> for traits::ProgramClause<'tcx> {
654 EnumTypeFoldableImpl! {
655 impl<'tcx> TypeFoldable<'tcx> for traits::Clause<'tcx> {
656 (traits::Clause::Implies)(clause),
657 (traits::Clause::ForAll)(clause),
661 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<traits::Clause<'tcx>> {
662 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
664 .map(|t| t.fold_with(folder))
665 .collect::<SmallVec<[_; 8]>>();
666 folder.tcx().intern_clauses(&v)
669 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
670 self.iter().any(|t| t.visit_with(visitor))
674 impl<'tcx, C> TypeFoldable<'tcx> for chalk_engine::ExClause<C>
676 C: traits::ExClauseFold<'tcx>,
677 C::Substitution: Clone,
678 C::RegionConstraint: Clone,
680 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
681 <C as traits::ExClauseFold>::fold_ex_clause_with(
687 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
688 <C as traits::ExClauseFold>::visit_ex_clause_with(
695 impl<'tcx, C> Lift<'tcx> for chalk_engine::ExClause<C>
697 C: chalk_engine::context::Context + Clone,
698 C: traits::ExClauseLift<'tcx>,
700 type Lifted = C::LiftedExClause;
702 fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted> {
703 <C as traits::ExClauseLift>::lift_ex_clause_to_tcx(self, tcx)
707 EnumTypeFoldableImpl! {
708 impl<'tcx, C> TypeFoldable<'tcx> for chalk_engine::DelayedLiteral<C> {
709 (chalk_engine::DelayedLiteral::CannotProve)(a),
710 (chalk_engine::DelayedLiteral::Negative)(a),
711 (chalk_engine::DelayedLiteral::Positive)(a, b),
713 C: chalk_engine::context::Context + Clone,
714 C::CanonicalConstrainedSubst: TypeFoldable<'tcx>,
717 EnumTypeFoldableImpl! {
718 impl<'tcx, C> TypeFoldable<'tcx> for chalk_engine::Literal<C> {
719 (chalk_engine::Literal::Negative)(a),
720 (chalk_engine::Literal::Positive)(a),
722 C: chalk_engine::context::Context + Clone,
723 C::GoalInEnvironment: Clone + TypeFoldable<'tcx>,
726 CloneTypeFoldableAndLiftImpls! {
727 chalk_engine::TableIndex,