gpt4 book ai didi

rust - 为什么没有围栏的评论会触发 doctest?

转载 作者:行者123 更新时间:2023-11-29 07:50:24 26 4
gpt4 key购买 nike

<分区>

我在 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 应该用 ``` 围起来,这里不是这种情况。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com