rust-lang / rust-lang/rustfmt

rustfmt does not respect brace_style when formatting imports

Open
#5,545 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-imports C-feature-request P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

With:

hard_tabs = true
braces_style = "AlwaysNextLine"
control_brace_style = "AlwaysNextLine"
group_imports = "StdExternalCrate"
imports_granularity = "One"
imports_indent = "Block"
imports_layout = "Vertical"
indent_style = "Block"
newline_style = "Unix"
trailing_comma = "Vertical"

Current output:

use {
	colored::{
		ColoredString,
		Colorize,
	},
	std::{
		cmp::Ordering,
		fmt::{
			Display,
			Formatter,
		},
		io::{
			Read,
			Write,
		},
		ops::{
			ControlFlow,
			RangeInclusive,
		},
		result::Result,
	},
};

Expected output:

use
{
	colored::
	{
		ColoredString,
		Colorize,
	},
	std::
	{
		cmp::Ordering,
		fmt::
		{
			Display,
			Formatter,
		},
		io::
		{
			Read,
			Write,
		},
		ops::
		{
			ControlFlow,
			RangeInclusive,
		},
		result::Result,
	},
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the TOML configuration and Rust import shown in the report, then compare the current and expected layouts. Trace rustfmt's import-formatting path to determine where braces_style is ignored; done means formatting produces the expected brace placement without changing the other configured import behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.