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