]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0195.md
Rollup merge of #62514 - stephaneyfx:box-ffi, r=nikomatsakis
[rust.git] / src / librustc_error_codes / error_codes / E0195.md
1 Your method's lifetime parameters do not match the trait declaration.
2 Erroneous code example:
3
4 ```compile_fail,E0195
5 trait Trait {
6     fn bar<'a,'b:'a>(x: &'a str, y: &'b str);
7 }
8
9 struct Foo;
10
11 impl Trait for Foo {
12     fn bar<'a,'b>(x: &'a str, y: &'b str) {
13     // error: lifetime parameters or bounds on method `bar`
14     // do not match the trait declaration
15     }
16 }
17 ```
18
19 The lifetime constraint `'b` for bar() implementation does not match the
20 trait declaration. Ensure lifetime declarations match exactly in both trait
21 declaration and implementation. Example:
22
23 ```
24 trait Trait {
25     fn t<'a,'b:'a>(x: &'a str, y: &'b str);
26 }
27
28 struct Foo;
29
30 impl Trait for Foo {
31     fn t<'a,'b:'a>(x: &'a str, y: &'b str) { // ok!
32     }
33 }
34 ```