about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2015-06-29 16:00:57 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2015-06-30 19:21:17 +0200
commitc158be082f07c2b2ed0a5f1db33627709396ac63 (patch)
treead34bba019dc28f3f0dc42aa88cb4d56bd8cbc2e
parent40db46c6ba0d59e5ad9aa056a73055d2d3b83d04 (diff)
downloadrust-c158be082f07c2b2ed0a5f1db33627709396ac63.tar.gz
rust-c158be082f07c2b2ed0a5f1db33627709396ac63.zip
Add E0195 error explanation
-rw-r--r--src/librustc_typeck/diagnostics.rs39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs
index d4977c5d394..1e83c1b6900 100644
--- a/src/librustc_typeck/diagnostics.rs
+++ b/src/librustc_typeck/diagnostics.rs
@@ -1250,6 +1250,44 @@ information see the [opt-in builtin traits RFC](https://github.com/rust-lang/
 rfcs/blob/master/text/0019-opt-in-builtin-traits.md).
 "##,
 
+E0195: r##"
+Your method's lifetime parameters do not match the trait declaration.
+Erroneous code example:
+
+```
+trait Trait {
+    fn t<'a,'b:'a>(x: &'a str, y: &'b str);
+}
+
+struct Foo;
+
+impl Trait for Foo {
+    fn t<'a,'b>(x: &'a str, y: &'b str) { // error: lifetime parameters
+                                          //        or bounds on method `t`
+                                          //        do not match the trait
+                                          //        declaration
+    }
+}
+```
+
+The 'b lifetime constraints for `t` implementation does not match the
+trait declaration. Ensure lifetime declarations match exactly in both trait
+declaration and implementation. Example:
+
+```
+trait Trait {
+    fn t<'a,'b:'a>(x: &'a str, y: &'b str);
+}
+
+struct Foo;
+
+impl Trait for Foo {
+    fn t<'a,'b:'a>(x: &'a str, y: &'b str) { // ok!
+    }
+}
+```
+"##,
+
 E0197: r##"
 Inherent implementations (one that do not implement a trait but provide
 methods associated with a type) are always safe because they are not
@@ -1686,7 +1724,6 @@ register_diagnostics! {
     E0193, // cannot bound type where clause bounds may only be attached to types
            // involving type parameters
     E0194,
-    E0195, // lifetime parameters or bounds on method do not match the trait declaration
     E0196, // cannot determine a type for this closure
     E0203, // type parameter has more than one relaxed default bound,
            // and only one is supported