-
Notifications
You must be signed in to change notification settings - Fork 13.3k
cargo doc
and cargo test
erroneosly detect a documentation test
#123853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See also pub mod m1 {
/** This const
has a multiline document string.
*/
pub const GOOD_DOC: u32 = 1;
pub mod m2 {
/** This const
has a multiline document string.
*/
pub const BAD_DOC: u32 = 0;
}
pub mod m3 {
/** This const
*
* has a multiline document string.
*/
pub const GOOD_DOC: u32 = 0;
}
} Note that Likely whats happening is that However, I'm unsure how Moving this over for the rustdoc team to triage in case the inconsistency between |
Thanks for the report! This is a known issue where:
Closing as a duplicate of #59867, #64162, #88590, and #100225. |
The issue with multiline comments is that the `quote` crate simply places them inside /** */ comment which by markdown rules is considered as a code block when indented by more than 4 spaces. I have reported this in cargo project, and the maintainer has explained root cause of this behavior [1]. As far as I understand from comments on issue [2] this behavior is not going to change soon in rustdoc. This commit works around the issue by adding leading " * " to every line in a multiline doc string. This way `quote` takes the string as-as and indented code block is avoided. [1] rust-lang/rust#123853 [2] rust-lang/rust#100225
Problem
The following code snippet causes
cargo test
to fail.The failure is as follows:
Moreover,
.
cargo doc
generates the documentation ofBAD_DOC
constant as if it contained a code snippetInterestingly, the
GOOD_DOC
constant is treated correctly both incargo doc
andcargo test
, i.e., no doc-test is created for it and documentation is generated without a code snippet.This behavior is strange because the doc string is exactly the same in both constants. The only difference is that
BAD_DOC
is nested in another modulem2
.The expected behavior is to treat
BAD_DOC
the same way asGOOD_DOC
:cargo test
shouldn't failcargo doc
shouldn't generate a code snippetSteps
No response
Possible Solution(s)
No response
Notes
No response
Version
The text was updated successfully, but these errors were encountered: