-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix semicolon_outside_block
suggests wrongly when inside macros
#14954
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
Conversation
rustbot has assigned @samueltardieu. Use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a hard-time convincing myself that all this is necessary:
!block.span.from_expansion()
is already checked inSemicolonBlock::check_stmt()
- It looks like adding
&& stmt.span.contains(block.span)
into the guard inSemicolonBlock::check_stmt()
passes all the tests you add
Can you think of other test cases that would pass with your changes and fail with the proposed guard?
You are right about the first point. But for the second one, I think in mac!(
{ <- block
another_mac!(); // <- stmt
}
); |
I'm not sure I understand: your code is called by
This is why I was asking of a test case where my proposed addition to the guard in |
To make sure I am perfectly clear, what I am saying is that if I take the original code from fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &Stmt<'_>) {
match stmt.kind {
StmtKind::Expr(Expr {
kind: ExprKind::Block(block, _),
..
}) if !block.span.from_expansion() && stmt.span.contains(block.span) => { (note the added then all the uitests pass, including the ones you have added in the current PR. So I am wondering where the behavior difference might be. |
Oh I see, I've added the guard to the wrong place. In this case, I think your idea is right. I'm updating this PR to this better version. Thank you! |
Closes #14926
changelog: [
semicolon_outside_block
] fix wrong suggestions when inside macros