Description
Summary
I think this lint should warn to sort function arguments alphabetically. This is helpful in large and complex projects where you have many arguments on some functions (especially close to the root when you have numerous configurations from various envs that all have to be distributed throughout various parts of the program). Alphabetic sorting helps find the args I'm looking for more easily/quickly in the list of arguments to some function.
I think the user should be able to toggle this feature on/off via "fn_args"
keyword in here:
https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#source-item-ordering
Lint Name
source-item-ordering
Reproducer
I tried this code:
fn main() {
let a = "a".to_string();
let b = "b".to_string();
let c = "c".to_string();
lol(b, a, c);
}
pub(crate) fn lol(b: String, a: String, c: String) {
dbg!(&b);
dbg!(&a);
dbg!(&c);
}
I expected to see this happen:
lint should tell me to sort the function arguments for lol()
alphabetically like this:
pub(crate) fn lol(a: String, b: String, c: String) {
dbg!(&b);
dbg!(&a);
dbg!(&c);
}
Instead, this happened:
silence
Version
rustc 1.87.0 (17067e9ac 2025-05-09)
binary: rustc
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
commit-date: 2025-05-09
host: x86_64-unknown-linux-gnu
release: 1.87.0
LLVM version: 20.1.1