问题描述
为了对代码进行基准测试,我在项目的 cargo.toml
中添加了以下几行:
[dev-dependencies]
criterion = "0.3"
[[bench]]
name = "samples"
harness = false
运行 cargo bench
后,我收到很多类似以下的错误:
Compiling criterion v0.3.4
error[E0603]: module `export` is private
--> C:\Development\Rust\cargo\registry\src\github.com-1ecc6299db9ec823\criterion-0.3.4\src\connection.rs:201:17
|
201 | #[derive(Debug,Deserialize)]
| ^^^^^^^^^^^ private module
|
note: the module `export` is defined here
--> C:\Development\Rust\cargo\registry\src\github.com-1ecc6299db9ec823\serde-1.0.123\src\lib.rs:275:5
|
275 | use self::__private as export;
在我看来,错误消息表明 serde
和 criterion
之间存在问题。但是我在两个项目问题中都没有发现这个错误信息,所以我的工作区可能有隐藏的原因。
一些附加信息:
- 项目是使用 nightly 工具链编译的
- 在
cargo.toml
中只有一个显式依赖项(proc 宏),它传递引用syn
、quote
和proc-macro2
解决方法
您的依赖关系图中的 serde
版本和 serde_derive
版本不匹配。您需要使用 cargo update
使它们同步。两者必须始终具有相同的版本号。