Skip to content

Conversation

@shepmaster
Copy link
Member

No description provided.

Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is properly gated behind the 2027 style edition, and corresponds to style guide guidance (https://doc.rust-lang.org/beta/style-guide/statements.html):

Use a semicolon where an expression has void type, even if it could be propagated.

Comment on lines +1047 to +1055
// TODO[reviewer-help]: This is roughly "does it end in a
// curly". There might be a helper for this, or cases I'm
// missing.
ast::ExprKind::Loop(..)
| ast::ExprKind::While(..)
| ast::ExprKind::ForLoop { .. }
| ast::ExprKind::Let(..)
| ast::ExprKind::If(..)
| ast::ExprKind::Match(..) => false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about macros that use curly braces?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative here might be to use span_to_snippet and check if the returned string ends in }.

Copy link
Member Author

@shepmaster shepmaster Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about macros that use curly braces?

This appears to work with the current code as I'd want it to, but I couldn't tell you why...

Before

    loop {
        dummy! {}
    }
    loop {
        dummy!()
    }
    loop {
        dummy![]
    }

After

    loop {
        dummy! {}
    }
    loop {
        dummy!();
    }
    loop {
        dummy![];
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to work as I'd expect, but I couldn't tell you why...

Probably maybe that the block macro is a statement..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be to use span_to_snippet

I changed it to this

            _ => {
                let is_curly = self
                    .opt_snippet(expr.span())
                    .is_some_and(|s| s.ends_with("}"));

                if is_curly {
                    return false;
                }

                // Checking the edition as before 2024 the lack of a

And the tests still passed, so I think it's up to you to decide which is a more reasonable path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add two more test cases:

  • One for rustfmt-edition: 2024 and rustfmt-style_edition: 2024
  • One for rustfmt-edition: 2021 and rustfmt-style_edition: 2027

In both case I wouldn't expect us to add a ;

rhs,
},
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

rhs,
},
}
};
Copy link
Contributor

@ytmimi ytmimi Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this a necessary change? If not I'd prefer we revert it since we try not to change existing test cases.

@ytmimi ytmimi added the A-2027-style-edition Area: style edition 2027 label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants