我正在写一些rust文档示例(正在编译中):
/// ```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
| ^^^^^^^
我是不是应该取消这个警告..还是这里有什么不对劲?
发布于 2019-04-17 23:41:54
您可以通过在代码块中使用有效的Rust代码来修复错误。
这会重现问题:
/// ```rust
///
/// ```
pub fn foo() {}
不要在代码块前添加虚假的空格。在Markdown中,四个空格被视为代码的开头,因此您实际上完成了与HTML相同的操作:
<code>```rust ```</code>
正如它告诉您的,```
不是有效的Rust代码。
https://stackoverflow.com/questions/55731174
复制相似问题