-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Clippy 1.0 #2476
Clippy 1.0 #2476
Conversation
cc @rust-lang/dev-tools @rust-lang/compiler This isn't tagged T-Compiler (maybe it should be?) but the uplift stuff does impact the compiler team. |
text/0000-clippy-uno.md
Outdated
Clippy, the linter for Rust, has been a nightly-only plugin to Rust for many years. | ||
In that time, it's grown big, but it's nightly-only nature makes it pretty hard to use. | ||
|
||
The eventual plan is to integrate it in Rustup á la Rustfmt/RLS so that you can simply fetch prebuilt binaries |
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.
It's à
😄
text/0000-clippy-uno.md
Outdated
Clippy aims to follow the general Rust style. It may be somewhat opiniated in some situations. | ||
|
||
In general clippy is intended to be used with a liberal sprinkling of `#[allow()]` and `#[warn()]`; _it is okay_ to | ||
disagree with Clippy's choices. This is a weaker philosophy than that behind rustc's lints, where usually flipping |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
text/0000-clippy-uno.md
Outdated
# Rationale and alternatives | ||
[alternatives]: #alternatives | ||
|
||
We don't particularly _need_ a 1.0, however it's good to have a milestone here, and a general idea of stability as we move forward in this process. |
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.
I once gave a talk about clippy and the first question asked by the audience was "Why the fuck is your version 0.0.97? Are you ever going to increase from 0.0?". This was more than 100 versions ago.
We need to move away from 0.0 at some point.
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.
Such an angry audience you had :) I hope they are not representative for the rust community.
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.
They weren't particularly angry, just really astonished by such a weird version. I also mentioned semver in a previous talk about Rust at the same conference, and then here I am, presenting a tool that seems like it doesn't want to commit to a proper versioning. Kind of ironic for a tool that aims to help you with Rust good practises.
text/0000-clippy-uno.md
Outdated
* [cmp_owned](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#cmp_owned) (creating owned instances for comparing with others, e.g. `x == "foo".to_string()`) | ||
* [mutex_atomic](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#mutex_atomic) (using a mutex where an atomic value could be used instead) | ||
* [box_vec](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#box_vec) (usage of `Box<Vec<T>>`, vector elements are already on the heap) | ||
* [useless_vec](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#useless_vec) (useless `vec!`) |
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.
I don't see temporary_cstring_as_ptr
which is definitely something I would like uplifted.
IIRC at the time of the creation of this lint we had found a quite few instances of this, for which we opened PRs, but new instances might have appeared by now.
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.
It's not generally wrong if used as a function argument, it's "just" a very common source of dangling pointers because a simple refactoring can easily turn correct code into UB. Any use of CString::new(...).unwrap().as_ptr()
outside a function argument is definitely wrong.
More detailed discussion can be found here
cc the other clippy maintainers @llogiq @mcarton @phansch @flip1995 @birkenfeld |
A few thoughts:
Also:
|
Still redirect them to the crate if the crate still works the same way. If not, remove the lint.
Would you like to come up with a list of potential renames? 😄 It seems like you have a rough idea of a consistent system here. We can make this happen; and it doesn't need to happen in-band in this RFC (we can cross link a PR). It's in scope for this RFC but I want to break out discussions as much as possible. Edit: Discussion at rust-lang/rust-clippy#2845
That's a fair point, could you open a rustc PR for that? We can deprecate the lint if it ends up landing. But that's out of scope for this RFC so I don't want to discuss it here too much 😄 Edit: Moved to rust-lang/rust-clippy#2846 |
This comment has been minimized.
This comment has been minimized.
text/0000-clippy-uno.md
Outdated
* [boxed_local](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#boxed_local) (using `Box<T>` where unnecessary) | ||
* [large_enum_variant](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#large_enum_variant) (large size difference between variants on an enum) | ||
* [manual_memcpy](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#manual_memcpy) (manually copying items between slices) | ||
* [unused_collect](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#unused_collect) (`collect()`ing an iterator without using the result; this is usually better written as a for loop) |
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.
It's a good lint; For the suggestion part, I think using .for_each(|elt| { .. })
is also idiomatic (if you don't need to break
and stuff).
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.
I think specifics like this should be raised as issues on the repo, not here 😄
We're dealing with the broad idea of the lints here, not the specific ones.
(This RFC can become huge in scope otherwise)
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.
Yeah that makes sense. 😆
This comment has been minimized.
This comment has been minimized.
Apologies in advance if this is a major land-grab, but since uplifting to rustc is being discussed here and that compiler lints are under the purview of the lang team, I'm also adding
In honour of Clippy, the Office Assistant. I think it is pretty cute. |
I feel like lints fall under the purview of the compiler team; at least this discussion has been ongoing with the compiler team, not the lang team. (I didn't include the compiler team myself because I wanted them to make the decision of adding themselves) Lints are a UI feature, not a language feature. Alternative implementations need not use the same set of lints. |
Cc @oli-obk bug in your script? :) |
@Manishearth Hmm well; It could be that the RFC policy - language design document is outdated, but just today we did discuss #2471 in the lang team meeting. My rationale for continued Anyways, if the language team agrees this is not under their purview they can remove themselves... ;) EDIT: nominating this for the next lang meeting so the question of purview itself can be dealt with quickly. |
text/0000-clippy-uno.md
Outdated
|
||
[online]: http://rust-lang-nursery.github.io/rust-clippy/current/ | ||
|
||
Please leave comments on thoughts about these lints -- if their categorization is correct, if they should exist at all, and if we should be uplifting them to the compiler. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
text/0000-clippy-uno.md
Outdated
* [useless_vec](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#useless_vec) (useless `vec!`) | ||
|
||
### perf (Warn) | ||
* [naive_bytecount](https://rust-lang-nursery.github.io/rust-clippy/master/index.html#naive_bytecount) (use of naive `<slice>.filter(|&x| x == y).count()` to count byte values) |
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.
It feels weird to me for an official rust-lang
-organization tool to ever recommend a non-rust-lang
crate in a lint, no matter how good it is. I never want to see an issue for "my crate for this is better than that one, so you should be recommending mine instead".
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.
If there is an ambiguity, we can just recommend all the crates anyone wants recommended. We don't rate crates.
I think some lints are lang team things, but not in general. I consider that document outdated because Rust has had a semi official "no new lints" policy for ages which effectively means it never got exercised, and historically we've added lints along with language changes to support them, or without an RFC at all in case of things like soundness deprecations. Compiler lints are as important as diagnostics in the feel of the language imo, but diagnostics are squarely a compiler team concern. Docs are also in a similar space here. Ultimately everything we do here impacts Rust the language 😄 I basically want to avoid this becoming a three team RFC 😄 And also, this is something we've been discussing with the compiler team for a while which is why I want to avoid additional churn and rehashing things we've discussed. |
@rfcbot resolve clippy-toml-stability discussed a bit in the meeting, clippy.toml is explicitly unstable |
@rfcbot reviewed |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@rfcbot concern cargo-clippy Following from the discussion of rust-lang/rust-clippy#1358, I'm not certain that I think the most expedient thing would be to edit the RFC to avoid asserting that the interface to clippy will be a I'm also concerned that the rules for uplifting lints into rustc are too vague, but I think we're managing that discussion well enough on rust-lang/rust#53224 and don't think I need to register a concern here regarding that. |
This is intentional, we don't want to legislate too strongly what gets uplifted, more of give some guidelines and mention that uplifts should happen. Actual uplifts should be discussed case by case, as they are in rust-lang/rust#53224 Regarding cargo clippy, I personally like having Amended RFC to punt on cargo-clippy till later. |
@rfcbot resolve cargo-clippy I think we have a shared understanding of what we still don't have consensus on.
I've raised a concern about that on the issue linked, which we should continue discussing there. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
Request to allow For exmaple,
would be allowed to become:
|
@U007D That seems completely sensible, but I don't think it should be part of this RFC. Would you consider proposing a general RFC to allow scoped attributes and warning names like |
The final comment period, with a disposition to merge, as per the review above, is now complete. |
🎉 This RFC has merged! Tracking issue at rust-lang/rust-clippy#3343 (the tracking issue is a bit weird since there's no stabilization step) |
This RFC proposes a Clippy 1.0 in preparation for being shipped via Rustup. It aims to get community consensus on the current state of Clippy lints, as well as on what lints we should uplift to the compiler directly if any.
See also: The Future of Clippy
Co-written by @oli-obk
Rendered
Tracking issue