Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implement remove_nested_blocks option#6489

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
karolzwolak wants to merge4 commits intorust-lang:master
base:master
Choose a base branch
Loading
fromkarolzwolak:remove_nested_blocks

Conversation

karolzwolak
Copy link
Contributor

@karolzwolakkarolzwolak commentedFeb 26, 2025
edited
Loading

Implements new feature that removes nested blocks#5616.
The feature is similar toremove_nested_parens. Blocks with any sort of comments or attributes,unsafe andconst blocks will not be removed. This however will not remove all nested blocks, instead it will leave the innermost block (similar toremove_nested_parens). That behavior differs from suggested in the issue, and I'm not sure which one is better.

I'm not fully satisfied with my implementation, so any suggestions are appreciated.
I also was not sure what do do if nested blocks are of different kind (nestedconst and/orunsafe blocks), so I decided to only remove 'naked' blocks, and just never removeconst andunsafe blocks. There is some merit to removingunsafe orconst blocks when only blocks of one kind are nested, but for the sake of consistency I decided to not do that. An example of such problematic situation:

// rustfmt-remove_nested_blocks: truefnfoo(){}fnone_kind(){{// <- this block would be removed if not for this commentconst{const{}}}}fnmixed(){unsafe{unsafe{{// <- this block would be removed if not for this commentconst{const{{// this block will not be removed regardless of the commentfoo();}}}}}}}

As I said, for now bothmixed, andone_kind functions would only remove the blocks annotated by comments.
I'm open for suggestions regarding the behavior, since the feature in the original issue was very loosely defined (also blocks are more tricky than parentheses)

inner_label,
true,
context,
shape,
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'm not sure if this is correct, it does seem to work, but I'm confused what the shape is even for.

@karolzwolakkarolzwolak changed the titleadd tests and config spec for new option remove_nested_blocksImplement remove_nested_blocks optionFeb 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@karolzwolak@rustbot

[8]ページ先頭

©2009-2025 Movatter.jp