【问题标题】:Compile error when running cargo bench (criterion/serde)运行 cargo bench 时出现编译错误(criterion/serde)
【发布时间】:2021-02-06 09:30:57
【问题描述】:

我在项目的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;

错误消息在我看来serdecriterion 之间存在问题。但是我在两个项目问题中都没有发现这个错误信息,所以我的工作区可能有隐藏的原因。

一些附加信息:

  • 项目是使用 nightly 工具链编译的
  • cargo.toml 中只有一个显式依赖项(proc 宏),它传递引用 synquoteproc-macro2

【问题讨论】:

    标签: rust rust-cargo serde rust-criterion


    【解决方案1】:

    您的依赖关系图中的serde 版本和serde_derive 版本不匹配。您需要使用cargo update 使它们同步。两者必须始终具有相同的版本号。

    【讨论】:

      猜你喜欢
      • 2016-10-04
      • 1970-01-01
      • 2022-01-20
      • 2012-06-24
      • 1970-01-01
      • 2020-10-30
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      相关资源
      最近更新 更多