Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=de3e0cab5a0a3a72f2840b824066f6f1
// OK: fn buggy_const<'a, const N: usize>(_a: &'a Option<[u8; N]>, _f: &str) -> &'a str {
fn buggy_const<const N: usize>(_a: &Option<[u8; N]>, _f: &str) -> &str {
return "";
}
fn main() {
buggy_const(&Some([69,69,69,69,0]), "test");
}
The current output is:
2 | fn buggy_const<const N: usize>(_a: &Option<[u8; N]>, _f: &str) -> &str {
| ---------------- ---- ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `arr` or `field`
help: consider introducing a named lifetime parameter
|
2 | fn buggy_const<const 'a, N: usize>(_a: &'a Option<[u8; N]>, _f: &'a str) -> &'a str {
| +++ ++ ++ ++
Ideally the output should look like:
2 | fn buggy_const<'a, const N: usize>(_a: &'a Option<[u8; N]>, _f: &'a str) -> &'a str {
| +++ ++ ++ ++
This issue is present with both stable (1.59) and nightly: 1.61.0-nightly -(2022-04-02 76d770ac21d9521db6a9)