about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2020-01-21 13:53:39 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2020-01-23 13:37:05 +0100
commit0f5ed4d2cdc3678cdd3a5c2dceb85a0ac8564f87 (patch)
treeb521d0320350762285bf3d33851636141e7cc180 /src
parentbf84eb538fd16743240434b3e837b36c35719fee (diff)
downloadrust-0f5ed4d2cdc3678cdd3a5c2dceb85a0ac8564f87.tar.gz
rust-0f5ed4d2cdc3678cdd3a5c2dceb85a0ac8564f87.zip
Clean up E0207 explanation
Diffstat (limited to 'src')
-rw-r--r--src/librustc_error_codes/error_codes/E0207.md30
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