diff options
| author | Yuki Okushi <huyuumi.dev@gmail.com> | 2020-01-28 10:48:10 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-28 10:48:10 +0900 |
| commit | dc33cd3500e6c59461e784253c4cb3ebffa97098 (patch) | |
| tree | 77e100f6fd35459f9765ca6bf535e36a639475a4 /src | |
| parent | 2bfa058074abbf28b1a35e89aad83a8d291fc38b (diff) | |
| parent | 0f5ed4d2cdc3678cdd3a5c2dceb85a0ac8564f87 (diff) | |
| download | rust-dc33cd3500e6c59461e784253c4cb3ebffa97098.tar.gz rust-dc33cd3500e6c59461e784253c4cb3ebffa97098.zip | |
Rollup merge of #68412 - GuillaumeGomez:clean-up-e0207, r=Dylan-DPC
Clean up E0207 explanation r? @Dylan-DPC
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_error_codes/error_codes/E0207.md | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/librustc_error_codes/error_codes/E0207.md b/src/librustc_error_codes/error_codes/E0207.md index 67b2063504c..21e7e461c75 100644 --- a/src/librustc_error_codes/error_codes/E0207.md +++ b/src/librustc_error_codes/error_codes/E0207.md @@ -1,3 +1,19 @@ +A type or lifetime parameter that is specified for `impl` is not constrained. + +Erroneous code example: + +```compile_fail,E0207 +struct Foo; + +impl<T: Default> Foo { + // error: the type parameter `T` is not constrained by the impl trait, self + // type, or predicates [E0207] + fn get(&self) -> T { + <T as Default>::default() + } +} +``` + Any type parameter or lifetime parameter of an `impl` must meet at least one of the following criteria: @@ -10,19 +26,7 @@ the following criteria: ### Error example 1 Suppose we have a struct `Foo` and we would like to define some methods for it. -The following definition leads to a compiler error: - -```compile_fail,E0207 -struct Foo; - -impl<T: Default> Foo { -// error: the type parameter `T` is not constrained by the impl trait, self -// type, or predicates [E0207] - fn get(&self) -> T { - <T as Default>::default() - } -} -``` +The previous code example has a definition which leads to a compiler error: The problem is that the parameter `T` does not appear in the implementing type (`Foo`) of the impl. In this case, we can fix the error by moving the type |
