Open YaLTeR opened 6 years ago
That lifetime is always going to be 'static
, you should just do data as *mut S<'static>
here.
Thanks, didn't know that. Then perhaps that should be specified in the warning text?
A note stating that all useless uses of the liftetime should be replaced with 'static
is a good idea
Can I pick this up? I'm a rust n00b :)
@andreicristianpetcu great! it's all yours. If you have any questions, you can post here or open a WIP PR showing what you tried and ask for help there.
Sorry I did not have time to work on this and I might not have in the future either :(
Is it possible that I could handle this issue, @oli-obk?
@JacksonCoder jup!
Great, thanks!
Should I make this a separate warning, or integrate it with the unused_lifetime
lint?
In the former case, we could call the lint unnecessary_lifetime
or something else, where it points out that since the lifetime is unused in the function definition, we can just replace the usage of that unused lifetime with 'static
.
In the latter case, is it possible to make 'notes' for a lint, just like with compiler warnings/errors for Rust? Because if so, we could basically make a note for each usage of that useless lifetime in similar wording to the former case.
The existing unused_lifetime
lint should be extended. The best thing would be to add a suggestion (with the span_suggestion
method) that replaces each lifetime with 'static
. You probably need to record the spans of all lifetimes, because I think this isn't happening today.
I'm using this type of stuff in a
-sys
-crate:and this triggers
unused_lifetime
.Playground with more context (also shows the #2677 issue): https://play.rust-lang.org/?gist=21a412537258ede9cbda42350501b90a&version=nightly