Skip to content

fix: semicolon_inside_block don't eat closing paren in ({0}); #15391

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

Closed
wants to merge 9 commits into from

Conversation

ada4a
Copy link
Contributor

@ada4a ada4a commented Aug 2, 2025

depends on #15390, but not critically

changelog: [semicolon_inside_block] don't eat closing paren in ({0});

fixes #15380

PS: this is almost identical to #15386 -- I wonder if there's a better way of doing this, given that pretty much anything in Rust can be wrapped in (an arbitrary number of) parens without change of meaning

@rustbot
Copy link
Collaborator

rustbot commented Aug 2, 2025

r? @samueltardieu

rustbot has assigned @samueltardieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 2, 2025
@breandead
Copy link

i wonder if it would not be better to not emit the suggestion at all when we have a block inside open brackets, that avoids the issues with making a statement into an expression; I don't think it makes much sense to drag the semicolon through the brackets, as the lints description is written in the docs it shouldnt do it imo

@ada4a
Copy link
Contributor Author

ada4a commented Aug 3, 2025

That does sound sensible. Although it still won't fix #15388, since that happens even without parens

let insert_span = tail.span.source_callsite().shrink_to_hi();
let remove_span = semi_span.with_lo(block.span.hi());
let remove_span = semi_span
.with_lo(semi_span.hi() - BytePos(1)) // the last byte of `semi_span` is the `;`, so shrink to that
Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh and I think this comment might actually be wrong because of this?

// For macro call semicolon statements (`mac!();`), the statement's span does not actually
// include the semicolon itself, so use `mac_call_stmt_semi_span`, which finds the semicolon
// based on a source snippet.

@ada4a ada4a marked this pull request as draft August 5, 2025 20:19
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 5, 2025
@ada4a
Copy link
Contributor Author

ada4a commented Aug 5, 2025

closed in favor of #15421

@ada4a ada4a closed this Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

semicolon-inside-block removes parens breaking code
4 participants