fix: avoid leaking wrapper space from doc comment code block formatting#6851
fix: avoid leaking wrapper space from doc comment code block formatting#6851utakotoba wants to merge 4 commits intorust-lang:mainfrom
Conversation
|
The fix handles the single-line wrapped case narrowly. Is there a scenario where |
Yes. The leak depends on the final wrapped formatted shape, not the original input shape. So if a multi-line function in a doc comment is reformatted such that the dummy wrapper collapses to The current fix is applied at extraction time, so it also covers that case. If the wrapped output stays multi-line, |
Co-authored-by: Matthew Hughes <matthewhughes934@gmail.com>
fixes #6832
Summary
Fixes a bug in doc comment code block formatting where
rustfmtcan introduce a trailing space and then report left behind trailing whitespace (iferror_on_unformatted = true).This happens with the following configuration:
Fix
Handle the single-line wrapped case when extracting the formatted code block body so wrapper-added whitespace is not preserved in the returned snippet.
The current fix is narrowly scoped to catch only single-line functions in doc comments. A simpler solution would be to wrap the final result with
remove_trailing_white_spaces(), but I don’t think it’s ideal since it would somehow impact more cases.