@@ -23,8 +23,8 @@ The new-style WF checking has not been implemented in rustc yet.
23
23
We give here a complete reference of the generated goals for each Rust
24
24
declaration.
25
25
26
- In addition with the notations introduced in the chapter about
27
- lowering rules, we'll introduce another notation: when WF checking a
26
+ In addition to the notations introduced in the chapter about
27
+ lowering rules, we'll introduce another notation: when checking WF of a
28
28
declaration, we'll often have to prove that all types that appear are
29
29
well-formed, except type parameters that we always assume to be WF. Hence,
30
30
we'll use the following notation: for a type ` SomeType<...> ` , we denote
@@ -212,11 +212,11 @@ trait Foo<T> {
212
212
213
213
struct OnlyClone<T: Clone> { ... }
214
214
215
- impl<T > Foo<Option<T >> for () {
215
+ impl<U > Foo<Option<U >> for () {
216
216
// We substitute type parameters from the trait by the ones provided
217
217
// by the impl, that is instead of having a `T: Clone` where clause,
218
- // we have an `Option<T >: Clone` one.
219
- type Assoc = OnlyClone<Option<T >> where Option<T >: Clone;
218
+ // we have an `Option<U >: Clone` one.
219
+ type Assoc = OnlyClone<Option<U >> where Option<U >: Clone;
220
220
}
221
221
222
222
impl<T> Foo<T> for i32 {
@@ -235,7 +235,7 @@ impl<T> Foo<T> for f32 {
235
235
236
236
So where clauses on associated types work * exactly* like where clauses on
237
237
trait methods: in an impl, we must substitute the parameters from the traits
238
- with values provided by the impl, we may omit them if we don't need them, and
238
+ with values provided by the impl, we may omit them if we don't need them, but
239
239
we cannot add new where clauses.
240
240
241
241
Now let's see the generated goal for this general impl:
@@ -255,7 +255,7 @@ forall<P1...> {
255
255
}
256
256
```
257
257
258
- Here is the most complex goal. As always, a first thing is that assuming that
258
+ Here is the most complex goal. As always, first, assuming that
259
259
the various where clauses hold, we prove that every type appearing in the impl
260
260
is well-formed, *** except*** types appearing in the receiver type
261
261
` SomeType<A2...> ` . Instead, we * assume* that those types are well-formed
@@ -269,7 +269,7 @@ input types of `SomeType<A2...>` are well-formed, we prove that
269
269
` WellFormed(SomeType<A2...>: Trait<A1...>) ` hold. That is, we want to prove
270
270
that ` SomeType<A2...> ` verify all the where clauses that might transitively
271
271
come from the ` Trait ` definition (see
272
- [ this subsection] ( ./implied-bounds#co-inductiveness-of-wellformed ) ).
272
+ [ this subsection] ( ./implied-bounds.md #co-inductiveness-of-wellformed ) ).
273
273
274
274
Lastly, assuming that the where clauses on the associated type ` WC_assoc ` hold,
275
275
we prove that ` WellFormed(SomeValue<A3...>: Bounds_assoc) ` hold. Again, we are
@@ -284,6 +284,10 @@ precise value of `<SomeType as Trait>::Assoc` is.
284
284
Some examples for the generated goal:
285
285
``` rust,ignore
286
286
trait Copy { }
287
+ // This is a program clause that comes from the trait definition above
288
+ // and that the trait solver can use for its reasonings. I'm just restating
289
+ // it here (and also the few other ones coming just after) so that we have
290
+ // them in mind.
287
291
// `WellFormed(Self: Copy) :- Implemented(Self: Copy).`
288
292
289
293
trait Partial where Self: Copy { }
@@ -392,22 +396,22 @@ trait PointerFamily {
392
396
393
397
struct BoxFamily;
394
398
395
- impl PointerFamily for CowFamily {
399
+ impl PointerFamily for BoxFamily {
396
400
type Pointer<T> = Box<T> where T: Debug;
397
401
}
398
402
// The generated goal is:
399
403
// ```
400
404
// forall<T> {
401
- // WellFormed(CowFamily : PointerFamily) &&
405
+ // WellFormed(BoxFamily : PointerFamily) &&
402
406
//
403
407
// if (FromEnv(T: Debug)) {
404
408
// WellFormed(Box<T>: Debug) &&
405
409
// WellFormed(Box<T>)
406
410
// }
407
411
// }
408
412
// ```
409
- // `WellFormed(CowFamily : PointerFamily)` amounts to proving
410
- // `Implemented(CowFamily : PointerFamily)`, which is ok thanks to our impl.
413
+ // `WellFormed(BoxFamily : PointerFamily)` amounts to proving
414
+ // `Implemented(BoxFamily : PointerFamily)`, which is ok thanks to our impl.
411
415
//
412
416
// `WellFormed(Box<T>)` is always true (there are no where clauses on the
413
417
// `Box` type definition).
0 commit comments