Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x: introduce 'cargo xfmt', a wrapper around 'cargo fmt'
Introduce 'xfmt', a wrapper around 'cargo fmt' which works around the issue that the 'merge_imports' config of rustfmt isn't stable. If you place an unstable config in a rustfmt.toml config file and run using a stable version of rustfmt the config is ignored and you get the following: $ cargo fmt Warning: can't set `merge_imports = true`, unstable features are only available in nightly channel. But if you instead pass the config using the '--config' option rustfmt happily applies and uses the unstable config: $ cargo fmt -- --config merge_imports=true Since there are enough people on the project that would like to see imports merged the new 'xfmt' wrapper uses the abbove workaround to ensure that imports are merged when running 'cargo xfmt'. If you also want to have the following behavior with your favorite editor (assuming your editor lets you pass additional flags to rustfmt) you can simply add '--config merge_imports=true' to the list of options your editor passes rustfmt when formatting rust code. For example with vim and the rust.vim plugin you would just need to add the following to your vimrc to have imports merged when rust.vim is used to format your code: let g:rustfmt_options = '--config merge_imports=true' Closes: diem#2926 Approved by: bothra90
- Loading branch information