Open
Description
Summary
clippy leaves in one of lifetimes and thus the code fails to compile
9 - fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {}
9 + fn f(PhantomData::<&'a u8>: PhantomData<&u8>) {}
Reproducer
I tried this code:
#![allow(dead_code)]
use std::marker::PhantomData;
fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {}
fn main() {}
I expected to see this happen:
warning: the following explicit lifetimes could be elided: 'a
--> src/main.rs:9:1
|
9 | fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
= note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
|
9 - fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {}
9 + fn f(PhantomData::<&u8>: PhantomData<&u8>) {}
Instead, this happened:
warning: the following explicit lifetimes could be elided: 'a
--> src/main.rs:9:1
|
9 | fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes
= note: `#[warn(clippy::needless_lifetimes)]` on by default
help: elide the lifetimes
|
9 - fn f<'a>(PhantomData::<&'a u8>: PhantomData<&'a u8>) {}
9 + fn f(PhantomData::<&'a u8>: PhantomData<&u8>) {}
Version
rustc 1.70.0-nightly (8a73f50d8 2023-03-11)
binary: rustc
commit-hash: 8a73f50d875840b8077b8ec080fa41881d7ce40d
commit-date: 2023-03-11
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7
Additional Labels
No response