rustdoc: inconsistent number of blank lines rendered top/bottom · Issue #102996 · rust-lang/rust (original) (raw)

I tried this code:

/// /// # use c::f; /// /// /// f()?; /// /// /// # Ok::<(), i32>(()) ///

I expected to see this happen: the same number of blank lines rendered on the top and bottom (0, 1 or 2 depending on what rule is followed).

Instead, this happened: currently it renders 2 on top, but 1 at the bottom, which is confusing.

I assume the idea is that the user does not add any blank line at all. However, since leaving 1 line in the bottom renders fine (even if the generated HTML does contain an extra newline), users may assume that it also works for the top, especially in projects that e.g. group hidden/not hidden uses at the top. For instance, the following appears to work fine:

/// /// # use c::very_common_thing; /// use c::f; /// /// f(very_common_thing)?; /// /// # Ok::<(), i32>(()) ///

Meta

Seems to have happened since a while ago, see #78695 for a related feature request that would fix this bug by leaving 0 lines on both top and bottom (which would be consistent).