Skip to content

Commit 01810f4

Browse files
committed
reviews
1 parent f2adb25 commit 01810f4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/param_env.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The type system relies on information in the environment in order for it to function correctly. This information is stored in the [`ParamEnv`][pe] type and it is important to use the correct `ParamEnv` when interacting with the type system.
66

7-
The information represented by `ParamEnv` is a list of in scope where clauses, and a [`Reveal`][reveal]. A `ParamEnv` typically corresponds to a specific item's environment however it can also be created with arbitrary data that is not derived from a specific item. In most cases `ParamEnv`s are initially created via the [`param_env` query][query] which returns a `ParamEnv` derived from the provided item's where clauses.
7+
The information represented by `ParamEnv` is a list of in-scope where-clauses, and a [`Reveal`][reveal]. A `ParamEnv` typically corresponds to a specific item's environment however it can also be created with arbitrary data that is not derived from a specific item. In most cases `ParamEnv`s are initially created via the [`param_env` query][query] which returns a `ParamEnv` derived from the provided item's where clauses.
88

99
If we have a function such as:
1010
```rust
@@ -21,7 +21,7 @@ A more concrete example:
2121
```rust
2222
// `foo` would have a `ParamEnv` of:
2323
// `[T: Sized, T: Clone]`
24-
fn foo<T: Clone>(a: T) -> (T, T) {
24+
fn foo<T: Clone>(a: T) {
2525
// when typechecking `foo` we require all the where clauses on `bar`
2626
// to hold in order for it to be legal to call. This means we have to
2727
// prove `T: Clone`. As we are type checking `foo` we use `foo`'s
@@ -37,14 +37,15 @@ Or alternatively an example that would not compile:
3737
```rust
3838
// `foo2` would have a `ParamEnv` of:
3939
// `[T: Sized]`
40-
fn foo2<T>(a: T) -> (T, T) {
40+
fn foo2<T>(a: T) {
4141
// When typechecking `foo2` we attempt to prove `T: Clone`.
4242
// As we are type checking `foo2` we use `foo2`'s environment
4343
// when trying to prove `T: Clone`.
4444
//
4545
// Trying to prove `T: Clone` with a `ParamEnv` of `[T: Sized]` will
4646
// fail as there is nothing in the environment telling the trait solver
47-
// that `T` implements `Clone`.
47+
// that `T` implements `Clone` and there exists no user written impl
48+
// that could apply.
4849
requires_clone(a);
4950
}
5051
```

0 commit comments

Comments
 (0)