-
Notifications
You must be signed in to change notification settings - Fork 889
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[unstable option] imports_layout #3361
Comments
What's necessary to stabilize this? |
There are some steps described in https://github.com/rust-lang/rustfmt/blob/master/Processes.md#stabilising-an-option. |
Why does I think it should be possible to try to fit all import statements into |
One good reason to prefer the |
A counter-argument for I recently had to do a rebase of a fairly complicated refactoring that moved lots of types around, and git rebase tools for in-line changes is not great. I would like to use this feature in mozilla-central once it’s stablised. |
I would love independent imports:
=>
As a possible alternative, I find this style super-friendly to git, immediately readable to my tastes, easy to play around with commenting-uncommenting. Is it possible to have it as an UPDATE: this has been implemented in the (currently unstable) option |
I think "independent imports" (#3361 (comment)) is outside of what this option is for, and is a discussion for #3362 instead. It's already been brought up there in #3362 (comment). AIUI the two options are orthogonal and the distinction is as follows: you can think of |
Shouldn't "mixed' be called "compressed" to match other similar options? |
This comment has been minimized.
This comment has been minimized.
Is this the same thing as |
Deno project is very interested in this setting as well (because we only use latests stable Rust toolchain). We'd prefer to format to have a single import per line (which is is very git diff friendly). |
I've opened #4991 to track |
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: - rust-lang/rustfmt#3361 - rust-lang/rustfmt#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
Is there anything missing to stabilize this option? |
@Progdrasil One of the big things missing is dealing with comments in imports; see #4991 (comment) |
linking #3286 |
The option |
@blyxyas PRs for doc improvements are always welcome 😁 |
I haven't made a PR because I don't know what it does |
@blyxyas no worries. I also couldn't have told you what it did before looking into it. From what I can tell it's meant to let you control the width at which imports wrap from being laid out horizontally to being laid out vertically, however I don't think we support parsing config options that take a value, and that might be why its not documented.
Line 90 in 38659ec
Lines 26 to 41 in 38659ec
I tried setting it from the command line and got an error
The |
It seems like there are some weird interactions with the use foo::{
a, b, b::{f, g}, c, d::e
};
use qux::{h, i};
use foo::{
a,
b,
b::{f, g},
c,
d::e,
};
use qux::{h, i};
use foo::{
a, b,
b::{f, g},
c,
d::e,
};
use qux::{h, i}; None of those really match up with what I would expect based on the examples, it seems like it jumps to multiline too quick. |
@tgross35 I believe the current formatting is correct based on the Nested import rules defined in the style guide |
I guess that does line up. Though I'm not sure why "Horizontal" breaks into a multiline group when it's not close to line length |
@tgross35 From the style guide: |
It was just my initial understanding that |
Can we make this stable as-is? Otherwise, it seems like perfect is being made the enemy of good. |
No.
That's not the case at all. There's a well documented set of criteria that our config options have to meet before they can be stabilized, not to mention that the Rust ecosystem takes the notion of stability pretty seriously. We don't stabilize something that has known bugs and known issues in interactions with other parts of the ecosystem (in this case other Rustfmt options) |
There are people who cannot use this even though it would provide value. |
Tracking issue for unstable option: imports_layout
The text was updated successfully, but these errors were encountered: