]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0088.md
Rollup merge of #92310 - ehuss:rustdoc-ice, r=estebank
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0088.md
1 #### Note: this error code is no longer emitted by the compiler.
2
3 You gave too many lifetime arguments. Erroneous code example:
4
5 ```compile_fail,E0107
6 fn f() {}
7
8 fn main() {
9     f::<'static>() // error: wrong number of lifetime arguments:
10                    //        expected 0, found 1
11 }
12 ```
13
14 Please check you give the right number of lifetime arguments. Example:
15
16 ```
17 fn f() {}
18
19 fn main() {
20     f() // ok!
21 }
22 ```
23
24 It's also important to note that the Rust compiler can generally
25 determine the lifetime by itself. Example:
26
27 ```
28 struct Foo {
29     value: String
30 }
31
32 impl Foo {
33     // it can be written like this
34     fn get_value<'a>(&'a self) -> &'a str { &self.value }
35     // but the compiler works fine with this too:
36     fn without_lifetime(&self) -> &str { &self.value }
37 }
38
39 fn main() {
40     let f = Foo { value: "hello".to_owned() };
41
42     println!("{}", f.get_value());
43     println!("{}", f.without_lifetime());
44 }
45 ```