Skip to content

fix additional semicolon during changing parentheses style - #6024

Open
rscprof wants to merge 1 commit into
rust-lang:mainfrom
rscprof:issue-6013
Open

rscprof wants to merge 1 commit into
rust-lang:mainfrom
rscprof:issue-6013

Conversation

@rscprof

@rscprof rscprof commented Jan 12, 2024

Copy link
Copy Markdown

#6013

Prevent add semicolon when changing parentheses style when using lazy_static. If we see that previous parentheses is round and we use the rule for lazy_static then we set flag about it and after it we simple skip insert semicolon during postprocessing spaces and semicolon.

@ytmimi ytmimi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @rscprof thanks for helping out on this one. I'd like to take a more general approach to solve this. Instead of adding state to the context specifically for lazy_static!, I think it would be better if the call to rewrite_macro and rewrite_macro_inner returned (Option<String>, Option<Delimiter>). Then in FmtVisitor::visit_mac we can make appropriate changes to the span we pass to push_rewrite in order to inform rustfmt that we've rewritten the entirety of the old macro call including the trailing ;.

We'll need to update some call sites, but that shouldn't be a big deal. Something like:

- rewrite_macro(...)
+ let (rewrite, _) = rewrite_macro(...);

We'll also need to tweak with_context to be generic over its return type.

@rscprof

rscprof commented Jan 12, 2024

Copy link
Copy Markdown
Author

Hi @ytmimi, I thought about returning pair, but I thought that it changes functions signatures drastically. I will change it tomorrow in your way.

@ytmimi ytmimi left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rscprof Thanks for your help! I finally had some time to get back around to reviewing this. I think your changes show that you understood what needed to be done to fix the issue. I think there were a few places where we could have made alternative code changes to simplify the diff. Also, I noticed in a few spots that you were conditionally returning the delimiters. I felt it was simpler to always return the rewritten delimiters if we could. Overall, good work so far, and I'd like to see the following changes.

Comment thread src/expr.rs Resolved
Comment thread src/items.rs Resolved
Comment thread src/macros.rs Resolved
Comment thread src/macros.rs Resolved
Comment thread src/macros.rs Resolved
Comment thread src/patterns.rs Resolved
Comment thread src/types.rs Resolved
Comment thread src/visitor.rs Resolved
Comment thread src/visitor.rs Resolved
Comment thread src/visitor.rs Resolved
@ytmimi

ytmimi commented Mar 28, 2024

Copy link
Copy Markdown
Contributor

@rscprof Can you take a look at the failures when you have a chance. Also, the rustfmt team strongly discourages merge commits. When you have a moment can you rebase these changes instead.

@rscprof

rscprof commented Mar 28, 2024

Copy link
Copy Markdown
Author

@rscprof Can you take a look at the failures when you have a chance. Also, the rustfmt team strongly discourages merge commits. When you have a moment can you rebase these changes instead.

Hi! I'm going to do all things in a week

@rscprof
rscprof requested a review from ytmimi March 28, 2024 20:59
@ytmimi

ytmimi commented Mar 28, 2024

Copy link
Copy Markdown
Contributor

@rscprof I'm still seeing the Merge branch 'master' into issue-6013 commit in the history. Can you please update the git history to remove that merge commit.

@rscprof
rscprof force-pushed the issue-6013 branch 2 times, most recently from 42466c8 to 25a9a5f Compare March 29, 2024 06:22
@rscprof

rscprof commented Mar 29, 2024 •

Copy link
Copy Markdown
Author

@rscprof I'm still seeing the Merge branch 'master' into issue-6013 commit in the history. Can you please update the git history to remove that merge commit.

I made one commit for radically simplifying history

@jieyouxu jieyouxu added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed pr-waiting-on-author labels Feb 23, 2026
@rustbot

rustbot commented Mar 13, 2026

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (possibly #6823) made this pull request unmergeable. Please resolve the merge conflicts.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants