-
Notifications
You must be signed in to change notification settings - Fork 926
Closing braces inside macros are double indented with hard tabs #3068
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
Labels
Comments
I also have the same issue, I think: #[macro_export]
macro_rules! define_invoke_proc_macro {
($macro_name: ident) => {
/// Implementation detail of other macros in this crate.
#[doc(hidden)]
#[macro_export]
macro_rules! $macro_name {
($proc_macro_name: ident ! $paren: tt) => {
#[derive($proc_macro_name)]
#[allow(unused)]
enum ProceduralMasqueradeDummyType {
// The magic happens here.
//
// We use an `enum` with an explicit discriminant
// because that is the only case where a type definition
// can contain a (const) expression.
//
// `(0, "foo").0` evalutes to 0, with the `"foo"` part ignored.
//
// By the time the `#[proc_macro_derive]` function
// implementing `#[derive($proc_macro_name)]` is called,
// `$paren` has already been replaced with the input of this inner macro,
// but `stringify!` has not been expanded yet.
//
// This how arbitrary tokens can be inserted
// in the input to the `#[proc_macro_derive]` function.
//
// Later, `stringify!(...)` is expanded into a string literal
// which is then ignored.
// Using `stringify!` enables passing arbitrary tokens
// rather than only what can be parsed as a const expression.
Input = (0, stringify! $paren ).0
}
}
}
}
} To: #[macro_export]
macro_rules! define_invoke_proc_macro {
($macro_name: ident) => {
/// Implementation detail of other macros in this crate.
#[doc(hidden)]
#[macro_export]
macro_rules! $macro_name {
($proc_macro_name: ident ! $paren: tt) => {
#[derive($proc_macro_name)]
#[allow(unused)]
enum ProceduralMasqueradeDummyType {
// The magic happens here.
//
// We use an `enum` with an explicit discriminant
// because that is the only case where a type definition
// can contain a (const) expression.
//
// `(0, "foo").0` evalutes to 0, with the `"foo"` part ignored.
//
// By the time the `#[proc_macro_derive]` function
// implementing `#[derive($proc_macro_name)]` is called,
// `$paren` has already been replaced with the input of this inner macro,
// but `stringify!` has not been expanded yet.
//
// This how arbitrary tokens can be inserted
// in the input to the `#[proc_macro_derive]` function.
//
// Later, `stringify!(...)` is expanded into a string literal
// which is then ignored.
// Using `stringify!` enables passing arbitrary tokens
// rather than only what can be parsed as a const expression.
Input = (0, stringify! $paren ).0
}
}
}
};
} Running rustfmt again indents the macro definition even more. I use soft tabs (i.e. spaces for tabs) in my editor, unless that's a specific rustfmt setting I'm unaware of. Pardon if this is an unrelated issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
rustfmt version:
rustfmt 0.99.5-nightly (90692a5 2018-09-26)
When
hard_tabs
is off, it is formatted like this:When
hard_tabs
is on, it is formatted like this:Closing braces have one more indentation when
hard_tabs
is on.The text was updated successfully, but these errors were encountered: