4 ms·
I'm always very happy to hear of companies using Rust. I'm especially happy to see that they're using clippy. It's not a core piece of their infra like hyper,
by Manishearth 10y ago
I'm always very happy to hear of companies using Rust.
I'm especially happy to see that they're using clippy. It's not a core piece of their infra like hyper, but it's still being used, which is nice.
How has it helped? Does it just keep the code clean or has it found mistakes and stuff like that too?
Loved the diagram, btw.
- jwilm 10y ago> How has it helped? Does it just keep the code clean or has it found mistakes and stuff like that too? Clippy hasn't found any bugs in our code that I'm aware of, but it has been invaluable even so. Clippy is really good at preventing bit-rot. When refactoring, it typically points out constructs that are no longer needed after other changes. It's great for teaching how to write Rust effectively and succinctly. I've certainly learned a lot from it. One example lint in this area is using `for item in list` vs `for item in list.into_iter()`. OnePush sets `#![cfg_attr(not(test), warn(result_unwrap_used))]` to make sure no `unwrap()`s are used in production code; all errors must be handled! `result_unwrap_used` has easily been the most valuable lint for us.
- Manishearth 10y agoNice to know, thanks! Yeah, clippy isn't solely for finding bugs -- a lot of the lints are about better style and cleaning up code, which often become useful after refactorings.
- ehsanu1 10y agoI'd really like to use clippy, but for production use I don't want to use anything but the stable Rust channel, whereas clippy apparently needs nightly Rust. Maybe I'm being overly cautious (OneSignal seems to do fine with just version pinning), but there's a reason nightly is separate from stable. It would be cool if I could configure cargo to only use nightly Rust when invoking clippy, and use stable for all dev/test/prod builds. Do you happen to know if that's possible?
- steveklabnik 10y agoWe definitely have plans to get clippy working on stable Rust; though I will say, with clippy, using nightly is less of a big deal, since it's not something you depend on, it's a tool you use. > if I could configure cargo to only use nightly Rust when invoking clippy, This is rustup run nightly cargo clippy or cargo +nightly clippy if you have rustup installed.
- rgawdzik 10y agoHey steve, Using clippy is not as straightforward as you put it because clippy and the latest nightly often are broken together. There would be much less hassle if it was a stable crate. Also no worries of backwards compatibility between stable/nightly. - rg
- steveklabnik 10y agoThat's totally fair; I've gotten lucky, I think, with the mis-matches. As mentioned, we certainly want to ship a "known good" one to address exactly what you're talking about, but until then, it's not _super_ onerous to use, IMHO.
- Manishearth 10y agoTo be clear, clippy can't ever be a true "stable" crate. What clippy does is rely on a whole ton of compiler internals so that it does not have to reimplement the compiler. These internals change, because the rust compiler is under active development. The plan for "stable" clippy is to bundle it with releases, precompiled. It will still use the internal APIs, but from a user's perspective they just have to `rustup component add clippy` and it will magically work.
- jwilm 10y ago`rustup component add clippy` Whoa, that's the first I've heard about this. Very exciting plans!
- 10y ago