Now that https://github.com/rust-lang/rust/issues/44494 has been stabilized, it would be nice to have a rustfmt option to reformat all imports into the use_nested_groups format.
We should decide what is the idiomatic way to use_nested_groups. For example, I had code like this:
use chalk_engine::{
context,
ExClause,
hh::HhGoal,
};
use rustc::{
infer::InferOk,
infer::canonical::{Canonical, CanonicalVarValues},
traits::ProgramClause,
ty::subst::Kind,
ty::{Binder, OutlivesPredicate, Region, Ty, TyCtxt},
};
which was reformatted into:
use chalk_engine::{context, ExClause, hh::HhGoal};
use rustc::{infer::InferOk, infer::canonical::{Canonical, CanonicalVarValues},
traits::ProgramClause, ty::subst::Kind,
ty::{Binder, OutlivesPredicate, Region, Ty, TyCtxt}};
The current output doesn't feel right to me; it's hard to skim the names etc, but I can see how rustfmt reached that point. I'm not sure if the style I was using is the "right" one, but I sort of like it: basically like having the first import (the crate) be special, and each line below is sort of like a use statement of its own.
@nrc Should this be reopened, or should we open a new issue to discuss the formatting that @nikomatsakis mentioned above?
@cramertj we should discuss on rust-lang-nursery/fmt-rfcs#24
Most helpful comment
We should decide what is the idiomatic way to
use_nested_groups. For example, I had code like this:which was reformatted into:
The current output doesn't feel right to me; it's hard to skim the names etc, but I can see how rustfmt reached that point. I'm not sure if the style I was using is the "right" one, but I sort of like it: basically like having the first import (the crate) be special, and each line below is sort of like a use statement of its own.