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 rustc_data_structures::accumulate_vec::AccumulateVec;
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 => bug!(), // FIXME: ape ConstEvalFailure?
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::SizedReturnType => Some(super::SizedReturnType),
207 super::SizedYieldType => Some(super::SizedYieldType),
208 super::RepeatVec => Some(super::RepeatVec),
209 super::FieldSized(item) => Some(super::FieldSized(item)),
210 super::ConstSized => Some(super::ConstSized),
211 super::SharedStatic => Some(super::SharedStatic),
212 super::BuiltinDerivedObligation(ref cause) => {
213 tcx.lift(cause).map(super::BuiltinDerivedObligation)
215 super::ImplDerivedObligation(ref cause) => {
216 tcx.lift(cause).map(super::ImplDerivedObligation)
218 super::CompareImplMethodObligation {
222 } => Some(super::CompareImplMethodObligation {
227 super::ExprAssignable => Some(super::ExprAssignable),
228 super::MatchExpressionArm { arm_span, source } => Some(super::MatchExpressionArm {
232 super::IfExpression => Some(super::IfExpression),
233 super::IfExpressionWithNoElse => Some(super::IfExpressionWithNoElse),
234 super::MainFunctionType => Some(super::MainFunctionType),
235 super::StartFunctionType => Some(super::StartFunctionType),
236 super::IntrinsicType => Some(super::IntrinsicType),
237 super::MethodReceiver => Some(super::MethodReceiver),
238 super::BlockTailExpression(id) => Some(super::BlockTailExpression(id)),
239 super::TrivialBound => Some(super::TrivialBound),
244 impl<'a, 'tcx> Lift<'tcx> for traits::DerivedObligationCause<'a> {
245 type Lifted = traits::DerivedObligationCause<'tcx>;
246 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
247 tcx.lift(&self.parent_trait_ref).and_then(|trait_ref| {
248 tcx.lift(&*self.parent_code)
249 .map(|code| traits::DerivedObligationCause {
250 parent_trait_ref: trait_ref,
251 parent_code: Rc::new(code),
257 impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCause<'a> {
258 type Lifted = traits::ObligationCause<'tcx>;
259 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
260 tcx.lift(&self.code).map(|code| traits::ObligationCause {
262 body_id: self.body_id,
269 impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
270 type Lifted = traits::Vtable<'tcx, ()>;
271 fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lifted> {
273 traits::VtableImpl(traits::VtableImplData {
277 }) => tcx.lift(&substs).map(|substs| {
278 traits::VtableImpl(traits::VtableImplData {
284 traits::VtableAutoImpl(t) => Some(traits::VtableAutoImpl(t)),
285 traits::VtableGenerator(traits::VtableGeneratorData {
289 }) => tcx.lift(&substs).map(|substs| {
290 traits::VtableGenerator(traits::VtableGeneratorData {
291 generator_def_id: generator_def_id,
296 traits::VtableClosure(traits::VtableClosureData {
300 }) => tcx.lift(&substs).map(|substs| {
301 traits::VtableClosure(traits::VtableClosureData {
307 traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested }) => {
308 tcx.lift(&fn_ty).map(|fn_ty| {
309 traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, nested })
312 traits::VtableParam(n) => Some(traits::VtableParam(n)),
313 traits::VtableBuiltin(n) => Some(traits::VtableBuiltin(n)),
314 traits::VtableObject(traits::VtableObjectData {
318 }) => tcx.lift(&upcast_trait_ref).map(|trait_ref| {
319 traits::VtableObject(traits::VtableObjectData {
320 upcast_trait_ref: trait_ref,
329 ///////////////////////////////////////////////////////////////////////////
330 // TypeFoldable implementations.
332 impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
333 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
335 cause: self.cause.clone(),
336 recursion_depth: self.recursion_depth,
337 predicate: self.predicate.fold_with(folder),
338 param_env: self.param_env.fold_with(folder),
342 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
343 self.predicate.visit_with(visitor)
347 BraceStructTypeFoldableImpl! {
348 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableImplData<'tcx, N> {
349 impl_def_id, substs, nested
350 } where N: TypeFoldable<'tcx>
353 BraceStructTypeFoldableImpl! {
354 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableGeneratorData<'tcx, N> {
355 generator_def_id, substs, nested
356 } where N: TypeFoldable<'tcx>
359 BraceStructTypeFoldableImpl! {
360 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableClosureData<'tcx, N> {
361 closure_def_id, substs, nested
362 } where N: TypeFoldable<'tcx>
365 BraceStructTypeFoldableImpl! {
366 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableAutoImplData<N> {
368 } where N: TypeFoldable<'tcx>
371 BraceStructTypeFoldableImpl! {
372 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
374 } where N: TypeFoldable<'tcx>
377 BraceStructTypeFoldableImpl! {
378 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableObjectData<'tcx, N> {
379 upcast_trait_ref, vtable_base, nested
380 } where N: TypeFoldable<'tcx>
383 BraceStructTypeFoldableImpl! {
384 impl<'tcx, N> TypeFoldable<'tcx> for traits::VtableFnPointerData<'tcx, N> {
387 } where N: TypeFoldable<'tcx>
390 EnumTypeFoldableImpl! {
391 impl<'tcx, N> TypeFoldable<'tcx> for traits::Vtable<'tcx, N> {
392 (traits::VtableImpl)(a),
393 (traits::VtableAutoImpl)(a),
394 (traits::VtableGenerator)(a),
395 (traits::VtableClosure)(a),
396 (traits::VtableFnPointer)(a),
397 (traits::VtableParam)(a),
398 (traits::VtableBuiltin)(a),
399 (traits::VtableObject)(a),
400 } where N: TypeFoldable<'tcx>
403 BraceStructTypeFoldableImpl! {
404 impl<'tcx, T> TypeFoldable<'tcx> for Normalized<'tcx, T> {
407 } where T: TypeFoldable<'tcx>
410 impl<'tcx> fmt::Display for traits::WhereClause<'tcx> {
411 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
412 use traits::WhereClause::*;
415 Implemented(trait_ref) => write!(fmt, "Implemented({})", trait_ref),
416 ProjectionEq(projection) => write!(fmt, "ProjectionEq({})", projection),
417 RegionOutlives(predicate) => write!(fmt, "RegionOutlives({})", predicate),
418 TypeOutlives(predicate) => write!(fmt, "TypeOutlives({})", predicate),
423 impl<'tcx> fmt::Display for traits::WellFormed<'tcx> {
424 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
425 use traits::WellFormed::*;
428 Trait(trait_ref) => write!(fmt, "WellFormed({})", trait_ref),
429 Ty(ty) => write!(fmt, "WellFormed({})", ty),
434 impl<'tcx> fmt::Display for traits::FromEnv<'tcx> {
435 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
436 use traits::FromEnv::*;
439 Trait(trait_ref) => write!(fmt, "FromEnv({})", trait_ref),
440 Ty(ty) => write!(fmt, "FromEnv({})", ty),
445 impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> {
446 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
447 use traits::DomainGoal::*;
450 Holds(wc) => write!(fmt, "{}", wc),
451 WellFormed(wf) => write!(fmt, "{}", wf),
452 FromEnv(from_env) => write!(fmt, "{}", from_env),
453 Normalize(projection) => write!(fmt, "Normalize({})", projection),
458 impl fmt::Display for traits::QuantifierKind {
459 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
460 use traits::QuantifierKind::*;
463 Universal => write!(fmt, "forall"),
464 Existential => write!(fmt, "exists"),
469 impl<'tcx> fmt::Display for traits::Goal<'tcx> {
470 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
474 Implies(hypotheses, goal) => {
475 write!(fmt, "if (")?;
476 for (index, hyp) in hypotheses.iter().enumerate() {
480 write!(fmt, "{}", hyp)?;
482 write!(fmt, ") {{ {} }}", goal)
484 And(goal1, goal2) => write!(fmt, "({} && {})", goal1, goal2),
485 Not(goal) => write!(fmt, "not {{ {} }}", goal),
486 DomainGoal(goal) => write!(fmt, "{}", goal),
487 Quantified(qkind, goal) => {
488 // FIXME: appropriate binder names
489 write!(fmt, "{}<> {{ {} }}", qkind, goal.skip_binder())
491 CannotProve => write!(fmt, "CannotProve"),
496 impl<'tcx> fmt::Display for traits::ProgramClause<'tcx> {
497 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
498 let traits::ProgramClause { goal, hypotheses } = self;
499 write!(fmt, "{}", goal)?;
500 if !hypotheses.is_empty() {
501 write!(fmt, " :- ")?;
502 for (index, condition) in hypotheses.iter().enumerate() {
506 write!(fmt, "{}", condition)?;
513 impl<'tcx> fmt::Display for traits::Clause<'tcx> {
514 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
515 use traits::Clause::*;
518 Implies(clause) => write!(fmt, "{}", clause),
520 // FIXME: appropriate binder names
521 write!(fmt, "forall<> {{ {} }}", clause.skip_binder())
527 EnumTypeFoldableImpl! {
528 impl<'tcx> TypeFoldable<'tcx> for traits::WhereClause<'tcx> {
529 (traits::WhereClause::Implemented)(trait_ref),
530 (traits::WhereClause::ProjectionEq)(projection),
531 (traits::WhereClause::TypeOutlives)(ty_outlives),
532 (traits::WhereClause::RegionOutlives)(region_outlives),
537 impl<'a, 'tcx> Lift<'tcx> for traits::WhereClause<'a> {
538 type Lifted = traits::WhereClause<'tcx>;
539 (traits::WhereClause::Implemented)(trait_ref),
540 (traits::WhereClause::ProjectionEq)(projection),
541 (traits::WhereClause::TypeOutlives)(ty_outlives),
542 (traits::WhereClause::RegionOutlives)(region_outlives),
546 EnumTypeFoldableImpl! {
547 impl<'tcx> TypeFoldable<'tcx> for traits::WellFormed<'tcx> {
548 (traits::WellFormed::Trait)(trait_ref),
549 (traits::WellFormed::Ty)(ty),
554 impl<'a, 'tcx> Lift<'tcx> for traits::WellFormed<'a> {
555 type Lifted = traits::WellFormed<'tcx>;
556 (traits::WellFormed::Trait)(trait_ref),
557 (traits::WellFormed::Ty)(ty),
561 EnumTypeFoldableImpl! {
562 impl<'tcx> TypeFoldable<'tcx> for traits::FromEnv<'tcx> {
563 (traits::FromEnv::Trait)(trait_ref),
564 (traits::FromEnv::Ty)(ty),
569 impl<'a, 'tcx> Lift<'tcx> for traits::FromEnv<'a> {
570 type Lifted = traits::FromEnv<'tcx>;
571 (traits::FromEnv::Trait)(trait_ref),
572 (traits::FromEnv::Ty)(ty),
576 EnumTypeFoldableImpl! {
577 impl<'tcx> TypeFoldable<'tcx> for traits::DomainGoal<'tcx> {
578 (traits::DomainGoal::Holds)(wc),
579 (traits::DomainGoal::WellFormed)(wf),
580 (traits::DomainGoal::FromEnv)(from_env),
581 (traits::DomainGoal::Normalize)(projection),
586 impl<'a, 'tcx> Lift<'tcx> for traits::DomainGoal<'a> {
587 type Lifted = traits::DomainGoal<'tcx>;
588 (traits::DomainGoal::Holds)(wc),
589 (traits::DomainGoal::WellFormed)(wf),
590 (traits::DomainGoal::FromEnv)(from_env),
591 (traits::DomainGoal::Normalize)(projection),
595 CloneTypeFoldableAndLiftImpls! {
596 traits::QuantifierKind,
599 EnumTypeFoldableImpl! {
600 impl<'tcx> TypeFoldable<'tcx> for traits::Goal<'tcx> {
601 (traits::Goal::Implies)(hypotheses, goal),
602 (traits::Goal::And)(goal1, goal2),
603 (traits::Goal::Not)(goal),
604 (traits::Goal::DomainGoal)(domain_goal),
605 (traits::Goal::Quantified)(qkind, goal),
606 (traits::Goal::CannotProve),
611 impl<'a, 'tcx> Lift<'tcx> for traits::Goal<'a> {
612 type Lifted = traits::Goal<'tcx>;
613 (traits::Goal::Implies)(hypotheses, goal),
614 (traits::Goal::And)(goal1, goal2),
615 (traits::Goal::Not)(goal),
616 (traits::Goal::DomainGoal)(domain_goal),
617 (traits::Goal::Quantified)(kind, goal),
618 (traits::Goal::CannotProve),
622 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<traits::Goal<'tcx>> {
623 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
625 .map(|t| t.fold_with(folder))
626 .collect::<AccumulateVec<[_; 8]>>();
627 folder.tcx().intern_goals(&v)
630 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
631 self.iter().any(|t| t.visit_with(visitor))
635 impl<'tcx> TypeFoldable<'tcx> for &'tcx traits::Goal<'tcx> {
636 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
637 let v = (**self).fold_with(folder);
638 folder.tcx().mk_goal(v)
641 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
642 (**self).visit_with(visitor)
646 BraceStructTypeFoldableImpl! {
647 impl<'tcx> TypeFoldable<'tcx> for traits::ProgramClause<'tcx> {
653 EnumTypeFoldableImpl! {
654 impl<'tcx> TypeFoldable<'tcx> for traits::Clause<'tcx> {
655 (traits::Clause::Implies)(clause),
656 (traits::Clause::ForAll)(clause),
660 impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Slice<traits::Clause<'tcx>> {
661 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
663 .map(|t| t.fold_with(folder))
664 .collect::<AccumulateVec<[_; 8]>>();
665 folder.tcx().intern_clauses(&v)
668 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
669 self.iter().any(|t| t.visit_with(visitor))
673 impl<'tcx, C> TypeFoldable<'tcx> for chalk_engine::ExClause<C>
675 C: traits::ExClauseFold<'tcx>,
676 C::Substitution: Clone,
677 C::RegionConstraint: Clone,
679 fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
680 <C as traits::ExClauseFold>::fold_ex_clause_with(
686 fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
687 <C as traits::ExClauseFold>::visit_ex_clause_with(
694 impl<'tcx, C> Lift<'tcx> for chalk_engine::ExClause<C>
696 C: chalk_engine::context::Context + Clone,
697 C: traits::ExClauseLift<'tcx>,
699 type Lifted = C::LiftedExClause;
701 fn lift_to_tcx<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Option<Self::Lifted> {
702 <C as traits::ExClauseLift>::lift_ex_clause_to_tcx(self, tcx)
706 EnumTypeFoldableImpl! {
707 impl<'tcx, C> TypeFoldable<'tcx> for chalk_engine::DelayedLiteral<C> {
708 (chalk_engine::DelayedLiteral::CannotProve)(a),
709 (chalk_engine::DelayedLiteral::Negative)(a),
710 (chalk_engine::DelayedLiteral::Positive)(a, b),
712 C: chalk_engine::context::Context + Clone,
713 C::CanonicalConstrainedSubst: TypeFoldable<'tcx>,
716 EnumTypeFoldableImpl! {
717 impl<'tcx, C> TypeFoldable<'tcx> for chalk_engine::Literal<C> {
718 (chalk_engine::Literal::Negative)(a),
719 (chalk_engine::Literal::Positive)(a),
721 C: chalk_engine::context::Context + Clone,
722 C::GoalInEnvironment: Clone + TypeFoldable<'tcx>,
725 CloneTypeFoldableAndLiftImpls! {
726 chalk_engine::TableIndex,