Reported by a session working on another repository, and reproduced here.
[style] wrap = "sentence" splits a one-line doc comment at its sentence boundary:
/// A short summary sentence. And a second sentence that makes this first paragraph considerably longer than the threshold clippy uses.
becomes
/// A short summary sentence.
/// And a second sentence that makes this first paragraph considerably longer than the threshold clippy uses.
Markdown joins consecutive lines with a space, so the rendered paragraph is byte-identical — which is the whole premise of the wrap rule.
But clippy's too_long_first_doc_paragraph stays quiet while a doc comment is physically one line and starts measuring the moment it spans two.
A change that altered no word and no rendering therefore fails a -D warnings build.
The reporting session saw seven at once from a whole-tree fix.
A doc comment that already carries an empty /// separator is unaffected, and fix --tidy preserves that separator — verified.
Why this is not obviously ours to fix
The separator clippy wants is a blank /// line, and inserting one does change the rendering: one paragraph becomes two.
"The rendered output is unchanged" is the premise the whole style axis rests on, and reflow.rs is written around it.
Volunteering a paragraph break would be the first thing this rule does that a reader would see in the output.
Against that: rustdoc treats the first paragraph as the item's summary line, so a summary that runs to two sentences is already wrong by rustdoc's own convention, and clippy is only noticing it late. Under that reading the break is a correction rather than an intrusion.
Options
- Nothing. The repository being formatted fixes its own doc comments, which is what the reporting session did. The cost is that
ocomment fix cannot be run unattended over a Rust tree with -D warnings, which is exactly where a commit hook runs it.
- Insert the separator when the split would leave a first paragraph over some length. Fixes the build, changes the rendering, and puts a clippy threshold inside
reflow.rs.
- Insert the separator after the first sentence of every doc comment the rule rewrites, on rustdoc's convention rather than clippy's threshold. Consistent, no foreign constant, and a larger change to what the rule does.
- Leave a doc comment's first line alone — reflow the body, never split the summary. Keeps the rendering promise, keeps the build green, and leaves the one line most likely to be over-long untouched.
4 looks closest to right, and none of them should go in without deciding what the wrap rule promises about rendering, because the answer is currently "everything".
Not urgent: the reporting repository has handled its own, and the separator round-trips.
Reported by a session working on another repository, and reproduced here.
[style] wrap = "sentence"splits a one-line doc comment at its sentence boundary:/// A short summary sentence. And a second sentence that makes this first paragraph considerably longer than the threshold clippy uses.becomes
Markdown joins consecutive lines with a space, so the rendered paragraph is byte-identical — which is the whole premise of the wrap rule.
But clippy's
too_long_first_doc_paragraphstays quiet while a doc comment is physically one line and starts measuring the moment it spans two.A change that altered no word and no rendering therefore fails a
-D warningsbuild.The reporting session saw seven at once from a whole-tree
fix.A doc comment that already carries an empty
///separator is unaffected, andfix --tidypreserves that separator — verified.Why this is not obviously ours to fix
The separator clippy wants is a blank
///line, and inserting one does change the rendering: one paragraph becomes two."The rendered output is unchanged" is the premise the whole style axis rests on, and
reflow.rsis written around it.Volunteering a paragraph break would be the first thing this rule does that a reader would see in the output.
Against that: rustdoc treats the first paragraph as the item's summary line, so a summary that runs to two sentences is already wrong by rustdoc's own convention, and clippy is only noticing it late. Under that reading the break is a correction rather than an intrusion.
Options
ocomment fixcannot be run unattended over a Rust tree with-D warnings, which is exactly where a commit hook runs it.reflow.rs.4 looks closest to right, and none of them should go in without deciding what the wrap rule promises about rendering, because the answer is currently "everything".
Not urgent: the reporting repository has handled its own, and the separator round-trips.