3 ms·
> The compiler also loves to tell you that your borrows aren't long-lived enough and you need to make them `'static`, when making them `'static` is almost alway
by estebank 5y ago
> The compiler also loves to tell you that your borrows aren't long-lived enough and you need to make them `'static`, when making them `'static` is almost always the opposite of what you actually do to resolve the problem
Most of the time the compiler complains about an unmet 'static lifetime, what it's actually talking about is about wanting an owned type. Sadly, I haven't gotten around to making those diagnostics more accurate (from the user's points of view).
> I've seen multiple colleagues new to Rust ask me for help with their code that has `&'static mut`, and when I tell them that's never going to work and ask them how they got there, it's always because the compiler told them to do it.
> Like [1] says, you eventually get the experience to ignore the compiler error message (or at least the "suggestions"), and instead understand the real problem and apply the real fix yourself.
I would appreciate bug reports at https://github.com/rust-lang/rust/issues/ https://github.com/rust-lang/rust/issues/ when encountering these kind of situations. If there's something worse than missing suggestions is inaccurate or misleading suggestions.