Skip to content

Commit e20f283

Browse files
mark-i-mscalexm
andcommitted
Fix a few things
Co-Authored-By: scalexm <[email protected]>
1 parent 8365209 commit e20f283

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/traits/wf.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ The new-style WF checking has not been implemented in rustc yet.
2323
We give here a complete reference of the generated goals for each Rust
2424
declaration.
2525

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
2828
declaration, we'll often have to prove that all types that appear are
2929
well-formed, except type parameters that we always assume to be WF. Hence,
3030
we'll use the following notation: for a type `SomeType<...>`, we denote
@@ -212,11 +212,11 @@ trait Foo<T> {
212212
213213
struct OnlyClone<T: Clone> { ... }
214214
215-
impl<T> Foo<Option<T>> for () {
215+
impl<U> Foo<Option<U>> for () {
216216
// We substitute type parameters from the trait by the ones provided
217217
// 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;
220220
}
221221
222222
impl<T> Foo<T> for i32 {
@@ -235,7 +235,7 @@ impl<T> Foo<T> for f32 {
235235

236236
So where clauses on associated types work *exactly* like where clauses on
237237
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
239239
we cannot add new where clauses.
240240

241241
Now let's see the generated goal for this general impl:
@@ -255,7 +255,7 @@ forall<P1...> {
255255
}
256256
```
257257

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
259259
the various where clauses hold, we prove that every type appearing in the impl
260260
is well-formed, ***except*** types appearing in the receiver type
261261
`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
269269
`WellFormed(SomeType<A2...>: Trait<A1...>)` hold. That is, we want to prove
270270
that `SomeType<A2...>` verify all the where clauses that might transitively
271271
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)).
273273

274274
Lastly, assuming that the where clauses on the associated type `WC_assoc` hold,
275275
we prove that `WellFormed(SomeValue<A3...>: Bounds_assoc)` hold. Again, we are
@@ -284,6 +284,10 @@ precise value of `<SomeType as Trait>::Assoc` is.
284284
Some examples for the generated goal:
285285
```rust,ignore
286286
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.
287291
// `WellFormed(Self: Copy) :- Implemented(Self: Copy).`
288292
289293
trait Partial where Self: Copy { }
@@ -392,22 +396,22 @@ trait PointerFamily {
392396
393397
struct BoxFamily;
394398
395-
impl PointerFamily for CowFamily {
399+
impl PointerFamily for BoxFamily {
396400
type Pointer<T> = Box<T> where T: Debug;
397401
}
398402
// The generated goal is:
399403
// ```
400404
// forall<T> {
401-
// WellFormed(CowFamily: PointerFamily) &&
405+
// WellFormed(BoxFamily: PointerFamily) &&
402406
//
403407
// if (FromEnv(T: Debug)) {
404408
// WellFormed(Box<T>: Debug) &&
405409
// WellFormed(Box<T>)
406410
// }
407411
// }
408412
// ```
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.
411415
//
412416
// `WellFormed(Box<T>)` is always true (there are no where clauses on the
413417
// `Box` type definition).

0 commit comments

Comments
 (0)