3
3
use crate :: cast:: { Cast , CastTo } ;
4
4
use crate :: fold:: shift:: Shift ;
5
5
use crate :: fold:: { Fold , Folder , Subst , SuperFold } ;
6
- use chalk_derive:: { Fold , HasInterner } ;
6
+ use crate :: visit:: { VisitResult , Visit , SuperVisit , Visitor } ;
7
+ use chalk_derive:: { Fold , HasInterner , Visit } ;
7
8
use chalk_engine:: fallible:: * ;
8
9
use std:: iter;
9
10
use std:: marker:: PhantomData ;
@@ -34,6 +35,9 @@ pub mod zip;
34
35
#[ macro_use]
35
36
pub mod fold;
36
37
38
+ #[ macro_use]
39
+ pub mod visit;
40
+
37
41
pub mod cast;
38
42
39
43
pub mod interner;
@@ -44,7 +48,7 @@ pub mod debug;
44
48
#[ cfg( any( test, feature = "default-interner" ) ) ]
45
49
pub mod tls;
46
50
47
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
51
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
48
52
/// The set of assumptions we've made so far, and the current number of
49
53
/// universal (forall) quantifiers we're within.
50
54
pub struct Environment < I : Interner > {
@@ -69,7 +73,7 @@ impl<I: Interner> Environment<I> {
69
73
}
70
74
}
71
75
72
- #[ derive( Clone , Debug , PartialEq , Eq , Hash , Fold ) ]
76
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Fold , Visit ) ]
73
77
pub struct InEnvironment < G : HasInterner > {
74
78
pub environment : Environment < G :: Interner > ,
75
79
pub goal : G ,
@@ -99,7 +103,7 @@ impl<G: HasInterner> HasInterner for InEnvironment<G> {
99
103
type Interner = G :: Interner ;
100
104
}
101
105
102
- #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Fold ) ]
106
+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Fold , Visit ) ]
103
107
pub enum TypeName < I : Interner > {
104
108
/// a type like `Vec<T>`
105
109
Struct ( StructId < I > ) ,
@@ -541,7 +545,7 @@ impl DebruijnIndex {
541
545
/// known. It is referenced within the type using `^1`, indicating
542
546
/// a bound type with debruijn index 1 (i.e., skipping through one
543
547
/// level of binder).
544
- #[ derive( Clone , PartialEq , Eq , Hash , Fold ) ]
548
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit ) ]
545
549
pub struct DynTy < I : Interner > {
546
550
pub bounds : Binders < QuantifiedWhereClauses < I > > ,
547
551
}
@@ -658,7 +662,7 @@ impl PlaceholderIndex {
658
662
}
659
663
660
664
// Fold derive intentionally omitted, folded through Ty
661
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
665
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
662
666
pub struct ApplicationTy < I : Interner > {
663
667
pub name : TypeName < I > ,
664
668
pub substitution : Substitution < I > ,
@@ -821,7 +825,7 @@ impl<I: Interner> ParameterData<I> {
821
825
}
822
826
}
823
827
824
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
828
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
825
829
pub struct AliasTy < I : Interner > {
826
830
pub associated_ty_id : AssocTypeId < I > ,
827
831
pub substitution : Substitution < I > ,
@@ -833,7 +837,7 @@ impl<I: Interner> AliasTy<I> {
833
837
}
834
838
}
835
839
836
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
840
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
837
841
pub struct TraitRef < I : Interner > {
838
842
pub trait_id : TraitId < I > ,
839
843
pub substitution : Substitution < I > ,
@@ -861,13 +865,13 @@ impl<I: Interner> TraitRef<I> {
861
865
}
862
866
863
867
/// Where clauses that can be written by a Rust programmer.
864
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
868
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
865
869
pub enum WhereClause < I : Interner > {
866
870
Implemented ( TraitRef < I > ) ,
867
871
AliasEq ( AliasEq < I > ) ,
868
872
}
869
873
870
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
874
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
871
875
pub enum WellFormed < I : Interner > {
872
876
/// A predicate which is true is some trait ref is well-formed.
873
877
/// For example, given the following trait definitions:
@@ -897,7 +901,7 @@ pub enum WellFormed<I: Interner> {
897
901
Ty ( Ty < I > ) ,
898
902
}
899
903
900
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
904
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
901
905
pub enum FromEnv < I : Interner > {
902
906
/// A predicate which enables deriving everything which should be true if we *know* that
903
907
/// some trait ref is well-formed. For example given the above trait definitions, we can use
@@ -929,7 +933,7 @@ pub enum FromEnv<I: Interner> {
929
933
/// A "domain goal" is a goal that is directly about Rust, rather than a pure
930
934
/// logical statement. As much as possible, the Chalk solver should avoid
931
935
/// decomposing this enum, and instead treat its values opaquely.
932
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
936
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
933
937
pub enum DomainGoal < I : Interner > {
934
938
Holds ( WhereClause < I > ) ,
935
939
@@ -1100,7 +1104,7 @@ impl<I: Interner> DomainGoal<I> {
1100
1104
}
1101
1105
}
1102
1106
1103
- #[ derive( Clone , PartialEq , Eq , Hash , Fold ) ]
1107
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit ) ]
1104
1108
pub struct EqGoal < I : Interner > {
1105
1109
pub a : Parameter < I > ,
1106
1110
pub b : Parameter < I > ,
@@ -1110,7 +1114,7 @@ pub struct EqGoal<I: Interner> {
1110
1114
/// type. A projection `T::Foo` normalizes to the type `U` if we can
1111
1115
/// **match it to an impl** and that impl has a `type Foo = V` where
1112
1116
/// `U = V`.
1113
- #[ derive( Clone , PartialEq , Eq , Hash , Fold ) ]
1117
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit ) ]
1114
1118
pub struct Normalize < I : Interner > {
1115
1119
pub alias : AliasTy < I > ,
1116
1120
pub ty : Ty < I > ,
@@ -1119,7 +1123,7 @@ pub struct Normalize<I: Interner> {
1119
1123
/// Proves **equality** between a projection `T::Foo` and a type
1120
1124
/// `U`. Equality can be proven via normalization, but we can also
1121
1125
/// prove that `T::Foo = V::Foo` if `T = V` without normalizing.
1122
- #[ derive( Clone , PartialEq , Eq , Hash , Fold ) ]
1126
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit ) ]
1123
1127
pub struct AliasEq < I : Interner > {
1124
1128
pub alias : AliasTy < I > ,
1125
1129
pub ty : Ty < I > ,
@@ -1261,7 +1265,7 @@ impl<V: IntoIterator> Iterator for BindersIntoIterator<V> {
1261
1265
/// Represents one clause of the form `consequence :- conditions` where
1262
1266
/// `conditions = cond_1 && cond_2 && ...` is the conjunction of the individual
1263
1267
/// conditions.
1264
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
1268
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
1265
1269
pub struct ProgramClauseImplication < I : Interner > {
1266
1270
pub consequence : DomainGoal < I > ,
1267
1271
pub conditions : Goals < I > ,
@@ -1583,7 +1587,7 @@ where
1583
1587
}
1584
1588
}
1585
1589
1586
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
1590
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
1587
1591
/// A general goal; this is the full range of questions you can pose to Chalk.
1588
1592
pub enum GoalData < I : Interner > {
1589
1593
/// Introduces a binding at depth 0, shifting other bindings up
@@ -1630,7 +1634,7 @@ pub enum QuantifierKind {
1630
1634
/// lifetime constraints, instead gathering them up to return with our solution
1631
1635
/// for later checking. This allows for decoupling between type and region
1632
1636
/// checking in the compiler.
1633
- #[ derive( Clone , PartialEq , Eq , Hash , Fold , HasInterner ) ]
1637
+ #[ derive( Clone , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
1634
1638
pub enum Constraint < I : Interner > {
1635
1639
LifetimeEq ( Lifetime < I > , Lifetime < I > ) ,
1636
1640
}
@@ -1837,13 +1841,13 @@ impl<'i, I: Interner> Folder<'i, I> for &SubstFolder<'i, I> {
1837
1841
/// substitution stores the values for the query's unknown variables,
1838
1842
/// and the constraints represents any region constraints that must
1839
1843
/// additionally be solved.
1840
- #[ derive( Clone , Debug , PartialEq , Eq , Hash , Fold , HasInterner ) ]
1844
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
1841
1845
pub struct ConstrainedSubst < I : Interner > {
1842
1846
pub subst : Substitution < I > , /* NB: The `is_trivial` routine relies on the fact that `subst` is folded first. */
1843
1847
pub constraints : Vec < InEnvironment < Constraint < I > > > ,
1844
1848
}
1845
1849
1846
- #[ derive( Clone , Debug , PartialEq , Eq , Hash , Fold , HasInterner ) ]
1850
+ #[ derive( Clone , Debug , PartialEq , Eq , Hash , Fold , Visit , HasInterner ) ]
1847
1851
pub struct AnswerSubst < I : Interner > {
1848
1852
pub subst : Substitution < I > , /* NB: The `is_trivial` routine relies on the fact that `subst` is folded first. */
1849
1853
pub constraints : Vec < InEnvironment < Constraint < I > > > ,
0 commit comments