Open
Description
I tried this code:
#![warn(unused_lifetimes)]
struct S;
pub fn repro()
where
for<'a> S: Clone,
{
}
pub fn main() {}
=>
warning: lifetime parameter `'a` never used
--> src/main.rs:6:13
|
6 | for<'a> S: Clone,
| ----^^-- help: elide the unused lifetime
|
note: the lint level is defined here
--> src/main.rs:1:9
|
1 | #![warn(unused_lifetimes)]
suggested code (cargo fix)
#![warn(unused_lifetimes)]
struct S;
pub fn repro()
where
S: Clone,
{
}
pub fn main() {}
does not compile:
error[E0277]: the trait bound `S: Clone` is not satisfied
--> src/main.rs:6:9
|
6 | S: Clone,
| ^^^^^^^^ the trait `Clone` is not implemented for `S`
|
= help: see issue #48214
help: consider annotating `S` with `#[derive(Clone)]`
|
2 + #[derive(Clone)]
3 | struct S;
|
help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
|
2 + #![feature(trivial_bounds)]
|
For more information about this error, try `rustc --explain E0277`.
error: could not compile `f` (bin "f") due to 1 previous error
rustc 1.89.0-nightly (1bbd62e54 2025-05-29)
binary: rustc
commit-hash: 1bbd62e547ba5cc08ccb44c27def3d33195d2dd5
commit-date: 2025-05-29
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5