@@ -45,7 +45,7 @@ fn main() {
45
45
}
46
46
```
47
47
48
- hence we don't want to repeat where clauses for input types because that would
48
+ Hence, we don't want to repeat where clauses for input types because that would
49
49
sort of duplicate the work of the programmer, having to verify that their types
50
50
are well-formed both when calling the function and when using them in the
51
51
arguments of their function. The same reasoning applies when using an ` impl ` .
@@ -75,15 +75,15 @@ fn fun_with_copy<T: Copy>(x: T) {
75
75
}
76
76
```
77
77
78
- The rationale for implied bounds for traits is that if a type implement ` Copy ` ,
79
- that is if there exists an ` impl Copy ` for that type, there * ought* to exist
78
+ The rationale for implied bounds for traits is that if a type implements ` Copy ` ,
79
+ that is, if there exists an ` impl Copy ` for that type, there * ought* to exist
80
80
an ` impl Clone ` for that type, otherwise the compiler would have reported an
81
81
error in the first place. So again, if we were forced to repeat the additionnal
82
82
` where SomeType: Clone ` everywhere whereas we already know that
83
83
` SomeType: Copy ` hold, we would kind of duplicate the verification work.
84
84
85
85
Implied bounds are not yet completely enforced in rustc, at the moment it only
86
- works for outlive requirements, super trait bounds and bounds on associated
86
+ works for outlive requirements, super trait bounds, and bounds on associated
87
87
types. The full RFC can be found [ here] [ RFC ] . We'll give here a brief view
88
88
of how implied bounds work and why we chose to implement it that way. The
89
89
complete set of lowering rules can be found in the corresponding
@@ -155,7 +155,7 @@ implied bounds from impls. Suppose we know that a type `SomeType<...>`
155
155
implements ` Bar ` and we want to deduce that ` SomeType<...> ` must also implement
156
156
` Foo ` .
157
157
158
- There are two possibilities: first one , we have enough information about
158
+ There are two possibilities: first, we have enough information about
159
159
` SomeType<...> ` to see that there exists a ` Bar ` impl in the program which
160
160
covers ` SomeType<...> ` , for example a plain ` impl<...> Bar for SomeType<...> ` .
161
161
Then if the compiler has done its job correctly, there * must* exist a ` Foo `
@@ -172,7 +172,7 @@ fn foo<T: Bar>() {
172
172
}
173
173
```
174
174
175
- that is, the information that ` T ` implements ` Bar ` here comes from the
175
+ That is, the information that ` T ` implements ` Bar ` here comes from the
176
176
* environment* . The environment is the set of things that we assume to be true
177
177
when we type check some Rust declaration. In that case, what we assume is that
178
178
` T: Bar ` . Then at that point, we might authorize ourselves to have some kind
@@ -182,8 +182,8 @@ only be done within our `foo` function in order to avoid the earlier
182
182
problem where we had a global clause.
183
183
184
184
We can apply these local reasonings everywhere we can have an environment
185
- -- i.e. when we can write where clauses -- that is inside impls,
186
- trait declarations and type declarations.
185
+ -- i.e. when we can write where clauses -- that is, inside impls,
186
+ trait declarations, and type declarations.
187
187
188
188
## Computing implied bounds with ` FromEnv `
189
189
@@ -224,7 +224,7 @@ forall<T> { FromEnv(T: A) :- FromEnv(T: B). }
224
224
forall<T> { Implemented(T: C) :- FromEnv(T: C). }
225
225
forall<T> { FromEnv(T: C) :- FromEnv(T: C). }
226
226
```
227
- So these clauses are defined globally (that is they are available from
227
+ So these clauses are defined globally (that is, they are available from
228
228
everywhere in the program) but they cannot be used because the hypothesis
229
229
is always of the form ` FromEnv(...) ` which is a bit special. Indeed, as
230
230
indicated by the name, ` FromEnv(...) ` facts can ** only** come from the
@@ -266,7 +266,7 @@ impl Bar for Y {
266
266
```
267
267
We must define what "legal" and "illegal" mean. For this, we introduce another
268
268
predicate: ` WellFormed(Type: Trait) ` . We say that the trait reference
269
- ` Type: Trait ` is well-formed is ` Type ` meets the bounds written on the
269
+ ` Type: Trait ` is well-formed if ` Type ` meets the bounds written on the
270
270
` Trait ` declaration. For each impl we write, assuming that the where clauses
271
271
declared on the impl hold, the compiler tries to prove that the corresponding
272
272
trait reference is well-formed. The impl is legal if the compiler manages to do
@@ -433,7 +433,7 @@ impl Foo for i32 {
433
433
The ` Foo ` trait definition and the ` impl Foo for i32 ` are perfectly valid
434
434
Rust: we're kind of recursively using our ` Foo ` impl in order to show that
435
435
the associated value indeed implements ` Foo ` , but that's ok. But if we
436
- translates this to our well-formedness setting, the compiler proof process
436
+ translate this to our well-formedness setting, the compiler proof process
437
437
inside the ` Foo ` impl is the following: it starts with proving that the
438
438
well-formedness goal ` WellFormed(i32: Foo) ` is true. In order to do that,
439
439
it must prove the following goals: ` Implemented(i32: Foo) ` and
0 commit comments