1 `'_` lifetime name or `&T` without an explicit lifetime name has been used
4 Erroneous code example:
6 ```compile_fail,E0106,E0637
7 fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
8 //^^ `'_` is a reserved lifetime name
9 if str1.len() > str2.len() {
16 fn and_without_explicit_lifetime<T>()
19 //^ `&` without an explicit lifetime name
24 First, `'_` cannot be used as a lifetime identifier in some places
25 because it is a reserved for the anonymous lifetime. Second, `&T`
26 without an explicit lifetime name cannot also be used in some places.
27 To fix them, use a lowercase letter such as `'a`, or a series
28 of lowercase letters such as `'foo`. For more information about lifetime
29 identifier, see [the book][bk-no]. For more information on using
30 the anonymous lifetime in Rust 2018, see [the Rust 2018 blog post][blog-al].
35 fn underscore_lifetime<'a>(str1: &'a str, str2: &'a str) -> &'a str {
36 if str1.len() > str2.len() {
43 fn and_without_explicit_lifetime<'foo, T>()
50 [bk-no]: https://doc.rust-lang.org/book/appendix-02-operators.html#non-operator-symbols
51 [blog-al]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html#more-lifetime-elision-rules