Open
Description
Summary
I think that arbitrary_source_item_ordering should stop comparing names that belong to different types of items.
For example I want main()
to always be at the top, and I want mod tests {}
to always be at the bottom. But if I have an function called send_to_database()
, this lint will send me an annoying suggestion to "put mod tests {}
before send_to_database()
. Yet turning off this lint entirely isn't desirable either because it's valuable to have items of the same type arranged alphabetically (for example fields in a struct).
Lint Name
arbitrary_source_item_ordering
Reproducer
I tried this code:
fn main() {
let structy = Structy::default();
let _field1 = structy.field1();
let _field_one = Structy::field1(&structy);
}
#[derive(Default)]
pub(crate) struct Structy {
field1: String,
}
impl Structy {
pub(crate) fn field1(&self) -> &String {
&self.field1
}
}
I saw this happen:
incorrect ordering of items (module item groupings specify another order)
I expected to see this happen:
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
Additional Labels
No response