Cargo
Clippy
Cargo | Clippy | |
---|---|---|
266 | 120 | |
12,551 | 11,249 | |
1.5% | 1.4% | |
10.0 | 10.0 | |
7 days ago | 3 days ago | |
Rust | Rust | |
Apache License 2.0 | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
Cargo
-
Things I know about Git commits
The more I've been doing open source maintenance and contributions where there isn't as much context between the code author and reviewer, the more I've been pushing for a little more than this.
- Add tests in a commit *before* the fix. They should pass, showing the behavior before your change. Then, the commit with your change will update the tests. The diff between these commits represents the change in behavior. This helps the author test their tests (I've written tests thinking they covered the relevant case but didn't), the reviewer to more precisely see the change in behavior and comment on it, and the wider community to understand what the PR description is about.
- Where reasonable, find ways to split code changes out of feature / fix commits into refactor commits. Reading a diff top-down doesn't tell you anything; you need to jump around a lot to see how the parts interact. By splitting it up, you can more quickly understand each piece and the series of commits tells a story of how the feature of fix came to be.
- Commits are atomic while PRs tell a story, as long as it doesn't get too big. Refactor are usually leading towards a goal and having them tied together with that goal helps to provide the context to understand it all. However, this has to be balanced with the fact that larger reviews mean more things are missed on each pass and its different things on each pass, causing a lot of "20 rounds of feedback in and I just noticed this major problem".
As an example of these is a recent PR of mine against Cargo: https://github.com/rust-lang/cargo/pull/14239
In particular, the refactors leading up to the final change made it so the actual fix was a one line change. It also linked out to the prior refactors that I split out into separate PRs to keep this one smaller.
- Crates-io 0.32.0 (accidentally) downgraded and published again as 0.31.1? (2020)
-
Surprisingly Powerful – Serverless WASM with Rust Article 1
Installing Trunk happens through Cargo. Remember, Cargo is more than a package manager, it also supports sub-commands.
-
Understanding Dependencies in Programming
Dependency Management in Other Languages: We've discussed Python and Node.js in this article, but dependency management is a universal concept in programming. Exploring how you handle dependencies in other languages like Java, C#, or Rust could be beneficial. (I think Rust's cargo is an excellent example of a package manager.)
- Cargo Script
-
Scriptisto: "Shebang interpreter" that enables writing scripts in compiled langs
Nice hack! Would it have been possible back then to use cargo to pull in some dependencies?
The clean solution of cargo script is here: https://github.com/rust-lang/cargo/issues/12207
-
Making Rust binaries smaller by default
Yes, I am sure this is going to be a part of Rust 1.77.0 and it will release on 21st March. I say that because of the tag in the PR (https://github.com/rust-lang/cargo/pull/13257#event-11505613...).
I'm no expert on Rust compiler development, but my understanding is that all code that is merged into master is available on nightly. If they're not behind a feature flag (this one isn't), they'll be available in a full release within 12 weeks of being merged. Larger features that need a lot more testing remain behind feature flags. Once they are merged into master, they remain on nightly until they're sufficiently tested. The multi-threaded frontend (https://blog.rust-lang.org/2023/11/09/parallel-rustc.html) is an example of such a feature. It'll remain nightly only for several months.
Again, I'm not an expert. This is based on what I've observed of Rust development.
-
You can't do that because I hate you
The author provides very surface-level criticism of two Rust tools, but they don't look into why those choices were made.
With about five minutes of my time, I found out:
wrap_comments was introduced in 2019 [0]. There are bugs in the implementation (it breaks Markdown tables), so the option hasn't been marked as stable. Progress on the issue has been spotty.
--no-merge-sources is not trivial to re-implement [1]. The author has already explained why the flag no longer works -- Cargo integrated the command, but not all of the flags. This commit [2] explains why this functionality was removed in the first place.
Rust is open source, so the author of this blog post could improve the state of the software they care about by championing these issues. The --no-merge-sources error message even encourages you to open an issue, presumably so that the authors of Cargo can gauge the importance of certain flags/features.
You could even do something much simpler, like adding a comment to the related issues mentioning that you ran into these rough edges and that it made your life a little worse, or with a workaround that you found.
Alternatively, you can continue to write about how much free software sucks.
[0]: https://github.com/rust-lang/rustfmt/issues/3347
[1]: https://github.com/rust-lang/cargo/pull/10344
[2]: https://github.com/rust-lang/cargo/commit/3842d8e6f20067f716...
-
Cargo has never frustrated me like npm or pip has. Does Cargo ever get frustrating? Does anyone ever find themselves in dependency hell?
You try to use it as a part of multi-language project, with an external build tool to tie it all together, and you discover that --out-dir flag is still not stabilized over some future compatibility concerns.
- State of Mozilla
Clippy
-
More than you've ever wanted to know about errors in Rust
I couldn't find it in the API guidelines either. From what I understand, the idea is that any trait bounds, which includes generic type parameter bounds and lifetime bound on a type (struct or enum) would be repeated back in the impl block
there is a nice discussion on this issue here: https://github.com/rust-lang/rust-clippy/issues/1689
-
New clippy lint: detecting `&mut` which could be `&` in function arguments
You should not blindly follow clippy lints. They are sometimes wrong. Another example https://github.com/rust-lang/rust-clippy/issues/9782 .
- Let else will finally be formatted by rustfmt soon
-
My deduplication solution written in Rust beats everything else: casync, borg...
I often write () = f() to assert that f() is unit. Unfortunately clippy warns on such code ( https://github.com/rust-lang/rust-clippy/issues/9048 ). There are very recent pull requests for this bug, so hopefully this bug will be fixed very soon. But meanwhile I invented this workaround: [()] = [f()] :)
-
Any open source projects willing to take in juniors?
Apart from running clippy on many projects being essential, clippy is also an exceptionally welcoming project, no matter your prior knowledge.
-
Any new Opensource projects in (rust) looking for contributors. I want to start my journey as an OSS contributor.
clippy is a great place to get started :) though it isn't exactly new.
-
I want to contribute in a big project
clippy is also pretty compiler-adjacent and unlike rust-analyzer uses rustc's internal APIs. Don't let the size of the code base scare you off! It's actually feasible for a newcomer to contribute even such a substantial change as a new lint, and we have issues labeled as "good first issue" that come with mentorship, so you don't need to go it alone.
-
rustc-plugin: A framework for writing plugins that integrate with the Rust compiler
Yes, you could use it to write a lint. Although you might find it easier to just fork Clippy and add your own lints to their existing framework.
-
Reading Rust
Check out the readme for more information.
-
Rust Tips and Tricks #PartOne
They are two of my favorite Rust tools. If you haven’t tried them yet, I highly recommend giving them a try. Clippy can detect various lints in your code and guide you towards writing more idiomatic code. To install Clippy, simply run rustup component add clippy, and to run it within your workspace, execute cargo clippy. For more details, visit Clippy’s GitHub repository.
What are some alternatives?
RustCMake - An example project showing usage of CMake with Rust
rustfmt - Format Rust code
overflower - A Rust compiler plugin and support library to annotate overflow behavior
vscode-rust
RustScan - 🤖 The Modern Port Scanner 🤖
rust.vim - Vim configuration for Rust.
cargo-check
rust-analyzer - A Rust compiler front-end for IDEs [Moved to: https://github.com/rust-lang/rust-analyzer]
crates.io - The Rust package registry
Rust for Visual Studio Code
cargo-dot - Generate graphs of a Cargo project's dependencies
sublime-rust - The official Sublime Text 4 package for the Rust Programming Language