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

Bad formatting of let-else in macro #5213

Closed
est31 opened this issue Feb 2, 2022 · 2 comments
Closed

Bad formatting of let-else in macro #5213

est31 opened this issue Feb 2, 2022 · 2 comments
Labels
a-macros bug Panic, non-idempotency, invalid code, etc. duplicate

Comments

@est31
Copy link
Member

est31 commented Feb 2, 2022

The following macro makes rustfmt as of nightly do bad formatting:

macro_rules! unwrap_some {
    ($name:ident) => {
        let Some($name) = $name else {
            panic!();
        };
    };
}

If you run it once, it moves the panic and the }; one indentation level to the right:

macro_rules! unwrap_some {
    ($id:ident) => {
        let Some($id) = $id else {
                    panic!();
                };
    };
}

This process is continued, until you reach this fixpoint:

macro_rules! unwrap_some {
    ($id:ident) => {
        let Some($id) = $id else {
                                                                                    panic!();
                                                                                };
    };
}

I file this bug not because the output is bad style (it is, but that is the purpose of #4914 to figure out), but because the rustfmt output from running it once is not a fixpoint.

@ytmimi
Copy link
Contributor

ytmimi commented Feb 2, 2022

Thanks for submitting this issue!

It's very likely that this is related to #5062 and #5044

@ytmimi ytmimi added bug Panic, non-idempotency, invalid code, etc. duplicate a-macros labels Feb 2, 2022
@ytmimi
Copy link
Contributor

ytmimi commented Jul 27, 2022

Going to close this as I believe this is a duplicate of the issues linked above

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

No branches or pull requests

2 participants