我正在编写一些生锈的doc示例(正在编译):
/// ```rust
/// # #[macro_use]
/// # extern crate ...
/// ...
/// ```
但cargo doc
给了我这个[错误的]警告:
warning: could not parse code block as Rust code
--> srml/support/src/dispatch.rs:105:5
|
105 | /// ```rust
| ________^
106 | | /// # #[macro_use]
| |_
|
= note: error from rustc: unknown start of token: `
help: mark blocks that do not contain Rust code as text
|
105 | /// ```textrust
| ^^^^^^^
我应该只是压制这个警告..还是这里有什么东西?
您可以通过在代码块中使用有效的Rust代码来修复错误。
这再现了问题:
/// ```rust
///
/// ```
pub fn foo() {}
不要在代码块之前添加虚假空格。在Markdown中,四个空格计为代码的开头,因此您实际上已经完成了HTML的等效操作:
<code>```rust ```</code>
正如它告诉你的那样,```
不是有效的Rust代码。