-
Notifications
You must be signed in to change notification settings - Fork 961
Description
Currently, rustfmt does not automatically merge multiple use statements from the same crate or module into a single, aligned use statement. For example, given the following imports:
use crate::backend::index::build::InsertBuildStats;
use crate::backend::index::update::UpdateStageResults;
use crate::utils::{self, fmt, MaybeDisplay};
use crate::{
backend::index::update::UpdateResults,
benchmark::inputs::async::InplaceDeleteMethod,
utils::{datafiles::UpdateOperationType, percentiles,},
};
It would be preferable if rustfmt could merge and align these into a single, more concise and organized statement, such as:
use crate::{
backend::index::{
build::InsertBuildStats,
update::{UpdateStageResults, UpdateResults},
},
benchmark::inputs::async::InplaceDeleteMethod,
utils::{self, fmt, MaybeDisplay, datafiles::UpdateOperationType, percentiles},
};
Expected Behavior:
rustfmt should automatically merge and align use statements that share a common root.
The merged statement should be formatted according to rustfmt’s existing style conventions for multi-line imports.
Motivation:
Merging imports improves code readability and reduces duplication.
It also helps maintain a cleaner and more idiomatic Rust codebase.
Request: Please consider adding an option or enhancing the default behavior to merge and align related use statements as illustrated above.