Skip to content

Skip fn signature when not selected with --file-lines#6884

Open
randomPoison wants to merge 2 commits intorust-lang:mainfrom
randomPoison:issue-6864-skip-fn-decl
Open

Skip fn signature when not selected with --file-lines#6884
randomPoison wants to merge 2 commits intorust-lang:mainfrom
randomPoison:issue-6864-skip-fn-decl

Conversation

@randomPoison
Copy link
Copy Markdown
Contributor

@randomPoison randomPoison commented May 5, 2026

Skip formatting the signature of a function when --file-lines does not overlap with the signature. Mostly fixes #6864. There's still a small edge case here where selecting the opening brace of the function will format the entire function signature, but I think the only way to handle that is to support partially formatting the signature, which is tracked by #6868.

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label May 5, 2026
@randomPoison
Copy link
Copy Markdown
Contributor Author

Actually I think the fix should go a bit deeper than what I have here currently. I think the out_of_file_lines_range! check should probably go in rewrite_fn_base that way it also covers required fns in trait defs. I'm digging into it a bit more to see if doing it that way causes any problems.

@randomPoison
Copy link
Copy Markdown
Contributor Author

Ah, moving the out_of_file_lines_range! check into rewrite_fn_base wouldn't actually impact trait definitions because we already have a similar check in visit_assoc_item that is skipping formatting of unselected trait items. We do eventually need to thread the file-lines info into rewrite_fn_base in order to fix #6868, but I think what I have in this PR is reasonable to cover the case of formatting the contents of a function without formatting its signature.

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

Labels

S-waiting-on-review Status: awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

file-lines modifies unselected fn signature lines when fn body is selected

2 participants