happy-kitchen-89482
11/13/2025, 3:25 AMfmt does only very basic import sorting within a single use or a single blank-line-delimited block, but it doesn't organize by group (std vs third party crate vs this crate). More powerful import sorting is an unstable feature, so requires use of Rust nightly. (cont. in thread)happy-kitchen-89482
11/13/2025, 3:25 AM./cargo +nightly fmt ... (and if you forgot the +nightly part you'd get errors because there would be unrecognized directives in rustfmt.toml.)happy-kitchen-89482
11/13/2025, 3:26 AM./cargo script to detect fmt and add the +nightly for ushappy-kitchen-89482
11/13/2025, 3:26 AMhappy-kitchen-89482
11/13/2025, 3:26 AMhappy-kitchen-89482
11/13/2025, 3:28 AM+nightly for fmt alone, and hack it in to ./cargo.happy-kitchen-89482
11/13/2025, 3:30 AMhappy-kitchen-89482
11/13/2025, 3:32 AMfast-nail-55400
11/13/2025, 3:44 AMrust-toolchain.toml.fast-nail-55400
11/13/2025, 3:45 AMcargo +nightly fmt PR every now and then.happy-kitchen-89482
11/13/2025, 3:50 AMhappy-kitchen-89482
11/13/2025, 3:50 AMhappy-kitchen-89482
11/13/2025, 3:50 AMhappy-kitchen-89482
11/13/2025, 3:51 AMfmt will accept the resultshappy-kitchen-89482
11/13/2025, 3:51 AM+nightly also requires some settings in rustfmt.toml that we can't leave in there for regular usehappy-kitchen-89482
11/13/2025, 3:52 AMhappy-kitchen-89482
11/13/2025, 3:53 AMsettings.json to get the new behavior:happy-kitchen-89482
11/13/2025, 3:53 AM"rust-analyzer.rustfmt.extraArgs": [ "+nightly", "--config", "imports_granularity=Module,group_imports=StdExternalCrate,reorder_modules=true" ],wide-midnight-78598
11/13/2025, 3:54 AMhappy-kitchen-89482
11/13/2025, 3:55 AMfmthappy-kitchen-89482
11/13/2025, 3:56 AM$ ./cargo +nightly fmt -- --config imports_granularity=Module,group_imports=StdExternalCrate,reorder_modules=truehappy-kitchen-89482
11/13/2025, 3:57 AMhappy-kitchen-89482
11/13/2025, 3:57 AMfast-nail-55400
11/13/2025, 5:58 AMwide-midnight-78598
11/13/2025, 3:04 PMwide-midnight-78598
11/13/2025, 3:05 PM