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

Unexpected formatting of macro with block when hard_tabs = true. #4542

Closed
nitsky opened this issue Nov 22, 2020 · 3 comments
Closed

Unexpected formatting of macro with block when hard_tabs = true. #4542

nitsky opened this issue Nov 22, 2020 · 3 comments
Assignees
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate

Comments

@nitsky
Copy link

nitsky commented Nov 22, 2020

Describe the bug

I am observing unexpected formatting of macro bodies when the macro emits a block wrapped in curly braces and hard_tabs = true.

To Reproduce

Run the following macro definition through rustfmt with hard_tabs = true:

Input:

macro_rules! example {
	() => {{ let x = 5; Ok(x) }};
}

Output:

macro_rules! example {
	() => {{
		let x = 5;
		Ok(x)
		}};
}

The output has an extra level indentation at the closing curly braces. This does not happen when hard_tabs = false or when the macro does not emit an enclosing block.

Expected behavior

#[macro_export]
macro_rules! example {
	() => {{
		let x = 5;
		Ok(x)
	}};
}

Meta

  • rustfmt version: 1.4.24-stable
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: rustfmt
@nitsky nitsky added the bug Panic, non-idempotency, invalid code, etc. label Nov 22, 2020
@calebcartwright
Copy link
Member

This has been fixed in source but not backported to a 1.x release. Let me see if I can squeeze this in the upcoming v.1.4.28 release

@calebcartwright
Copy link
Member

Closing as a duplicate of #4152, fix has been backported and will be in the next release

@nitsky
Copy link
Author

nitsky commented Nov 29, 2020

Thanks! 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. duplicate
Projects
None yet
Development

No branches or pull requests

2 participants