trait IsStatic {}
impl<'a: 'static> IsStatic for &'a () {}
#[derive(Clone)]
struct Immovable;
impl Copy for Immovable where for<'a> &'a (): IsStatic {}
fn main() {
let x = Immovable;
let _y = x; // Error!
}
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=4a69ff52aea9a5895ee753f6e93aaa49
error: implementation of `IsStatic` is not general enough
--> src/main.rs:11:14
|
11 | let _y = x; // Error!
| ^ implementation of `IsStatic` is not general enough
|
= note: `IsStatic` would have to be implemented for the type `&'0 ()`, for any lifetime `'0`...
= note: ...but `IsStatic` is actually implemented for the type `&'1 ()`, for some specific lifetime `'1`