]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0771.md
Rollup merge of #93556 - dtolnay:trailingcomma, r=cjgillot
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0771.md
1 A non-`'static` lifetime was used in a const generic. This is currently not
2 allowed.
3
4 Erroneous code example:
5
6 ```compile_fail,E0771
7 #![feature(adt_const_params)]
8
9 fn function_with_str<'a, const STRING: &'a str>() {} // error!
10 ```
11
12 To fix this issue, the lifetime in the const generic need to be changed to
13 `'static`:
14
15 ```
16 #![feature(adt_const_params)]
17
18 fn function_with_str<const STRING: &'static str>() {} // ok!
19 ```
20
21 For more information, see [GitHub issue #74052].
22
23 [GitHub issue #74052]: https://github.com/rust-lang/rust/issues/74052