diff --git a/src/librustc_error_codes/error_codes/E0207.md b/src/librustc_error_codes/error_codes/E0207.md index 67b2063504c07..21e7e461c753b 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 Foo { + // error: the type parameter `T` is not constrained by the impl trait, self + // type, or predicates [E0207] + fn get(&self) -> T { + ::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 Foo { -// error: the type parameter `T` is not constrained by the impl trait, self -// type, or predicates [E0207] - fn get(&self) -> T { - ::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