rustfmt: set imports_granularity to Item to minimize conflicts

Summary:
To make the codebase a bit more consistent and reduce conflicts. Similar to
Java.

Note: The fbsource Rust lint does not respect this file so it cannot conflict
with the fbcode rustfmt config. That means a more preserving (for what to group
in `{}` and what not), less controversial (when to use `{}` grouping is
controversial) choice `imports_layout = "HorizontalVertical"` (like
[black](https://github.com/psf/black) in Python) cannot be used at present.

See also:

- https://github.com/rust-lang/rustfmt/issues/3361
- https://github.com/rust-lang/rustfmt/issues/3362
- https://fb.workplace.com/groups/rust.language/posts/6720351014680123/
- https://fb.workplace.com/groups/rust.language/posts/5429720200409884/

This adds the config without changing the files.

Reviewed By: yancouto

Differential Revision: D31746731

fbshipit-source-id: 8e171829fd53691a59bf3b80cdc500c0b3993ba5
This commit is contained in:
Jun Wu 2021-10-19 11:05:23 -07:00 committed by Facebook GitHub Bot
parent d93fb54bfb
commit 33bd3f982c

12
eden/scm/.rustfmt.toml Normal file
View File

@ -0,0 +1,12 @@
# Inherit from fbcode root
edition = "2018"
merge_derives = false
use_field_init_shorthand = true
# Project specific config.
# Note: fbcode rustfmt does not respect these configs! So they cannot conflict
# with fbcode format options (i.e. run fbcode rustfmt and the result isn't
# changing).
# To minimize conflicts, and make things easier to grep.
imports_granularity = "Item"