Open
Description
Code
#[allow(dead_code)]
#[warn(single_use_lifetimes)]
fn foo<'a>(_items: impl IntoIterator<Item = &'a i64>) -> Vec<f64> {
vec![]
}
Current output
warning: lifetime parameter `'a` only used once
--> src/lib.rs:3:8
|
3 | fn foo<'a>(_items: impl IntoIterator<Item = &'a i64>) -> Vec<f64> {
| ^^ this lifetime... -- ...is used only here
|
note: the lint level is defined here
--> src/lib.rs:2:8
|
2 | #[warn(single_use_lifetimes)]
| ^^^^^^^^^^^^^^^^^^^^
help: elide the single-use lifetime
|
3 - fn foo<'a>(_items: impl IntoIterator<Item = &'a i64>) -> Vec<f64> {
3 + fn foo(_items: impl IntoIterator<Item = &i64>) -> Vec<f64> {
Desired output
No warning
Rationale and extra context
The feature required to elide the single use lifetime is unstable
Rust Version
$ rustc --version --verbose
rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5
and
$ rustc --version --verbose
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1