Documentation block comments always become doctests if indented too much #100225
Labels
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
In a project of mine, I use the following convention for doc comments (indentation is
____
):When indented by 5 spaces or more (i.e. 4 more than appear after
/**
), theLong description
part starts getting considered as an indented code block, to be tested as Rust code, despite the comment start/**
being at the same indentation level. It happens regardless of whether the empty line contains spaces or not.I ran into this when I started documenting the fields of
struct
-like variants in anenum
.Is it possible to fully support this style of doc-comments? I suppose that by the time
rustdoc
sees the documentation, the type of comment (line or block) and its indentation has been forgotten so it cannot be used by a de-indentation procedure. Would it be possible to special-case the first line and de-indent the others more?1 If block comments cannot be distinguished from line comments, that has the side effect of not considering the following a doctest anymore:Meta
Possibly-related issues: #59867, #63193, #64162, #88590
I initially discovered the issue on stable version 1.62.1 and confirmed using the playground that it still happens on nightly (1.65.0-nightly, 2022-08-06 2befdef).
Footnotes
I seem to remember that Python does this for its doc-strings. ↩
The text was updated successfully, but these errors were encountered: