fix(filter): preserve code around inline block comments#2715
Open
guyoron1 wants to merge 1 commit into
Open
Conversation
MinimalFilter dropped entire lines containing inline block comments like `int x = 5; /* comment */`, silently losing the code portion. Also affected closing lines of multi-line comments when followed by code. Restructure the block comment handler to extract and keep code before /* and after */, stripping only the comment itself. Fixes rtk-ai#2714
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MinimalFiltersilently dropping valid code on lines with inline block commentsint x = 5; /* comment */was entirely skipped — code before/*was lost (code loss bug)comment */ int z = 3;droppedint z = 3;/*and after*/, stripping only the comment itselfBefore / After
int x = 5; /* inline */int x = 5;kept/* multi\nline */ int z = 3;int z = 3;droppedint z = 3;kept/* full line comment */Test plan
test_inline_block_comment_preserves_code— verifies code before/*is kepttest_multiline_block_comment_closing_preserves_code_after— verifies code after*/is kepttest_full_line_block_comment_still_stripped— verifies full-line comments still removedcargo clippy --all-targetspassescargo test --allpassesFixes #2714