-
-
Notifications
You must be signed in to change notification settings - Fork 251
Address clippy::nursery
lint errors in macros.
#1317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address clippy::nursery
lint errors in macros.
#1317
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1317 |
Thanks! Maybe add brief comment about what they solve, or link to this PR. Otherwise looks good to me 🙂 |
f1e63b2
to
4c0d2e7
Compare
I think it won't hurt, albeit stakes are small (keeping dangling |
godot-ffi/src/plugins.rs
Outdated
// Triggered by $body. | ||
#[allow(clippy::significant_drop_tightening)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lint docs say:
Searches for elements marked with
#[clippy::has_significant_drop]
that could be early dropped but are in fact dropped at the end of their scopes. In other words, enforces the “tightening” of their possible lifetimes.
And you mentioned this is caused by the guard. But are you sure we cannot apply this to the code that actually causes this?
gdext/godot-ffi/src/plugins.rs
Lines 68 to 70 in 5470c11
let mut guard = $registry.lock().unwrap(); | |
guard.push($plugin); |
If not, then // Triggered by $body.
should at least be more descriptive. This isn't a common lint, and it has a very non-self-explanatory name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know what, at first I thought that writing $registry.lock().unwrap().push($plugin);
is not a good call, but now (after checking macro expansion via RustRover) I think it would be valid thing to do – we already do it the same way while registering constants & methods 🤔.
I also merged plugin_add
and plugin_add_inner
– after changes there is no need for separate inner.
let warning_message = | ||
format! { "godot-rust: OnEditor field {field} hasn't been initialized."}; | ||
|
||
// Note – triggers `clippy::useless_let_if_seq` lint if only one OnEditor field is present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment should be next to the #[allow]
.
4c0d2e7
to
9298387
Compare
Thanks! 👍 I was first worried because it looked like it would lock more, but it already does lock for every addition, so no changes there. If it ever becomes a performance bottleneck, we can always think about alternatives, but I like the simplicity here 🙂 |
Following code:
Was tripping
clippy::nursery
lints.This one happens when only one
OnEditor
field is present. Handled with#[allow(...)]
(making three versions depending on amount of OnEditor fields would be silly).Triggered by plugin registry,
let mut guard = ...; guard.do_something(...)
; handled with#[allow(...)]
(the lint is silly and I would like to keep it somewhat readable, thank you).