<分区>
我在 crate 中有以下注释代码:
/// Complex Expression
///
/// - The `Undefined` variant is used as a placeholder during code
/// transformations. It must never occur in the final result.
pub enum Cexp {
Undefined,
Unimplemented,
}
在 crate 上运行 cargo test
时,它会触发 doctest 运行,但编译失败。 (在 playground 中确保运行 TEST 而不是 BUILD。)
Doc-tests playground
running 1 test
test src/lib.rs - Cexp (line 3) ... FAILED
failures:
---- src/lib.rs - Cexp (line 3) stdout ----
error: unknown start of token: `
--> src/lib.rs:4:7
|
1 | - The `Undefined` variant is used as a placeholder during code
| ^
实际的错误消息无关紧要。 Rust 编译器在注释文本上窒息,这并不奇怪。但为什么这个评论会触发 doctest 运行?根据documentation doctests 应该用 ```
围起来,这里不是这种情况。