Open Manishearth opened 7 years ago
My main concern is discoverability of such a group. Newcomers have enough on their plate starting out with Rust. I can tell my students to enable it, but how will someone who finds Rust on their own know about such lints? We can't "detect" newcomers, because we can't differentiate them from someone who just created a small crate to test something.
Once clippy is stable, we could consider this by asking the rustc devs to
#[warn(clippy_for_new_rustaceans)]
into the cargo new --bin
template conditionally on some hidden config file which stores the date of the first rustc usage of the user and the number of crates created. Then the template could revert to its normal version after the count reaches 5 or the age reaches a month.I do intend to insert clippy into the docs along with rustfmt once it is stable.
I absolutely love the idea.
We should discuss this with the rustc team, because this would also be a good idea for error messages. Some errors are obvious mistakes made by new rustaceans, but after a while it will be a more complex issue
Of course, rustup
could also ask about the default when installing the toolchain.
Maybe make it default to assuming you're a newbie, but also make it easy to turn off? That way newbies are covered, and non-newbies should find it easy to disable.
It would be interesting to have a "newbie mode" (basically another lint group) that points out various features in your code, not necessarily suggesting fixes or anything.
For example
impl Trait for OtherTrait
can explain the difference betweenimpl<T: OtherTrait> Trait for T
and itself" orfn foo(mut x: Bar)
can tell you thatmut x
does not mutate the outer variable whenBar
is copy. Stuff like this, that doesn't work well as a lint (because there are plenty of good reasons to do it), but do merit a "watch out this may not do what you think" for newbies.Thoughts? Ideas for similar newbie hint-lints?