-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Conversation
for consistency
because of further issues with this lint
rustbot has assigned @samueltardieu. Use |
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 |
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 |
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.
oh and I think this comment might actually be wrong because of this?
rust-clippy/clippy_lints/src/semicolon_block.rs
Lines 107 to 109 in 5930e54
// 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. |
closed in favor of #15421 |
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