about summary refs log tree commit diff
diff options
context:
space:
mode:
authorpurple-ice <jaidy379@gmail.com>2019-01-03 20:15:01 +0200
committerGitHub <noreply@github.com>2019-01-03 20:15:01 +0200
commitc738e6042d2925bbfb045982fabe1f902f8b7c72 (patch)
treee53d6e8b4887de91f93579ea6e2b24e50b558d4b
parent2442823ef572a65092fbc46f6975633f983b50b6 (diff)
downloadrust-c738e6042d2925bbfb045982fabe1f902f8b7c72.tar.gz
rust-c738e6042d2925bbfb045982fabe1f902f8b7c72.zip
Extend E0106, E0261
Added an example that points out hardly obvious mistake one could make when writing impl for a new type.
-rw-r--r--src/librustc/diagnostics.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs
index 4bc52e82f9b..50beacf3e8c 100644
--- a/src/librustc/diagnostics.rs
+++ b/src/librustc/diagnostics.rs
@@ -362,6 +362,10 @@ struct Foo1 { x: &bool }
               // ^ expected lifetime parameter
 struct Foo2<'a> { x: &'a bool } // correct
 
+impl Foo2 { ... }
+  // ^ expected lifetime parameter
+impl<'a> Foo2<'a> { ... } // correct
+
 struct Bar1 { x: Foo2 }
               // ^^^^ expected lifetime parameter
 struct Bar2<'a> { x: Foo2<'a> } // correct
@@ -772,6 +776,24 @@ struct Foo<'a> {
     x: &'a str,
 }
 ```
+
+Implementations need their own lifetime declarations:
+    
+```
+// error, undeclared lifetime
+impl Foo<'a> {
+    ...
+}
+```
+
+Which are declared like this:
+
+```
+// correct
+impl<'a> Foo<'a> {
+    ...
+}
+```
 "##,
 
 E0262: r##"