Skip to content
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

use imports are wrapped unless double-nested imports are present #3286

Open
cramertj opened this issue Jan 10, 2019 · 4 comments
Open

use imports are wrapped unless double-nested imports are present #3286

cramertj opened this issue Jan 10, 2019 · 4 comments
Labels
Milestone

Comments

@cramertj
Copy link
Member

rustfmt gives this:

use {
    fidl_fuchsia_hardware_ethernet_ext::EthernetQueueFlags, futures::TryStreamExt, std::fs::File,
    structopt::StructOpt,
};

which is, IMO, pretty gross as it mixes imports from many different crates all together onto the same line.

Adding a group after _ext:: and adding Bar to it gives this:

use {
    fidl_fuchsia_hardware_ethernet_ext::{Bar, EthernetQueueFlags},
    futures::TryStreamExt,
    std::fs::File,
    structopt::StructOpt,
};

which is more like what I would expect. What's going on here? Is there a setting that can be enabled to always get the bottom layout, even when no nested groups are present?

@nrc nrc added the a-imports `use` syntax label Jan 16, 2019
@topecongiro
Copy link
Contributor

AFAIK using use statement like this has not been taken into account while implementing rustfmt. I think rustfmt should use vertical layout in the top-level import list.

Is there a setting that can be enabled to always get the bottom layout, even when no nested groups are present?

You could set imports_layout = "Vertical".

@cramertj
Copy link
Member Author

I think rustfmt should use vertical layout in the top-level import list.

I agree.

@topecongiro topecongiro added this to the 3.0.0 milestone Jun 29, 2020
@ytmimi
Copy link
Contributor

ytmimi commented Jul 19, 2022

@calebcartwright I think this can be closed. Although it's unstable, One could set the imports_layout option to something like imports_layout=HorizontalVertical to force a vertical layout when formatting horizontally is impossible. The reason why we get the Compressed formatting is because imports_layout=Mixed by default, and I don't think we can change the default value as that would be a breaking change. Or do we want to keep this open until imports_layout is stabilized?

input

use {
    fidl_fuchsia_hardware_ethernet_ext::EthernetQueueFlags, futures::TryStreamExt, std::fs::File,
    structopt::StructOpt,
}

output

use {
    fidl_fuchsia_hardware_ethernet_ext::EthernetQueueFlags,
    futures::TryStreamExt,
    std::fs::File,
    structopt::StructOpt,
};

@ytmimi
Copy link
Contributor

ytmimi commented Jul 20, 2022

Although they're unrelated issues, the use style being used here is being suggested as an option in #5360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants