@@ -20,6 +20,16 @@ the [notation given in this section](./traits-goals-and-clauses.html).
20
20
We sometimes insert "macros" like ` LowerWhereClause! ` into these
21
21
definitions; these macros reference other sections within this chapter.
22
22
23
+ ## Rule names and cross-references
24
+
25
+ Each of these lowering rules is given a name, documented with a
26
+ comment like so:
27
+
28
+ // Rule Foo-Bar-Baz
29
+
30
+ you can also search through the ` librustc_traits ` crate in rustc
31
+ to find the corresponding rules from the implementation.
32
+
23
33
## Lowering where clauses
24
34
25
35
When used in a goal position, where clauses can be mapped directly to
@@ -76,6 +86,7 @@ relationships between different kinds of domain goals. The first such
76
86
rule from the trait header creates the mapping between the ` FromEnv `
77
87
and ` Implemented ` predicates:
78
88
89
+ // Rule Implemented-From-Env
79
90
forall<Self, P1..Pn> {
80
91
Implemented(Self: Trait<P1..Pn>) :- FromEnv(Self: Trait<P1..Pn>)
81
92
}
@@ -89,6 +100,8 @@ The next few clauses have to do with implied bounds (see also
89
100
90
101
[ RFC 2089 ] : https://rust-lang.github.io/rfcs/2089-implied-bounds.html
91
102
103
+ // Rule Implied-Bound-From-Trait
104
+ //
92
105
// For each where clause WC:
93
106
forall<Self, P1..Pn> {
94
107
FromEnv(WC) :- FromEnv(Self: Trait<P1..Pn)
@@ -112,6 +125,8 @@ clauses** but also things that follow from them.
112
125
The next rule is related; it defines what it means for a trait reference
113
126
to be ** well-formed** :
114
127
128
+ // Rule WellFormed-TraitRef
129
+ //
115
130
// For each where clause WC:
116
131
forall<Self, P1..Pn> {
117
132
WellFormed(Self: Trait<P1..Pn>) :- Implemented(Self: Trait<P1..Pn>) && WellFormed(WC)
@@ -175,12 +190,16 @@ the rules by which `ProjectionEq` can succeed; these two clauses are discussed
175
190
in detail in the [ section on associated types] ( ./traits-associated-types.html ) ,,
176
191
but reproduced here for reference:
177
192
193
+ // Rule ProjectionEq-Normalize
194
+ //
178
195
// ProjectionEq can succeed by normalizing:
179
196
forall<Self, P1..Pn, Pn+1..Pm, U> {
180
197
ProjectionEq(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> = U) :-
181
198
Normalize(<Self as Trait<P1..Pn>>::AssocType<Pn+1..Pm> -> U)
182
199
}
183
200
201
+ // Rule ProjectionEq-Skolemize
202
+ //
184
203
// ProjectionEq can succeed by skolemizing, see "associated type"
185
204
// chapter for more:
186
205
forall<Self, P1..Pn, Pn+1..Pm> {
@@ -223,6 +242,7 @@ where WC
223
242
Let ` TraitRef ` be the trait reference ` A0: Trait<A1..An> ` . Then we
224
243
will create the following rules:
225
244
245
+ // Rule Implemented-From-Impl
226
246
forall<P0..Pn> {
227
247
Implemented(TraitRef) :- WC
228
248
}
@@ -245,6 +265,7 @@ where WC
245
265
246
266
We produce the following rule:
247
267
268
+ // Rule Normalize-From-Impl
248
269
forall<P0..Pm> {
249
270
forall<Pn+1..Pm> {
250
271
Normalize(<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm> -> T) :-
0 commit comments