【发布时间】:2020-12-19 23:33:10
【问题描述】:
当我使用my fork of async-trait 作为依赖项时,由于syn::* 类型相等,它无法编译。 All is green in async-trait CI checks。要重现,请启动一个新的 cargo lib 项目并添加到 Cargo.toml:
[dependencies]
syn = { version = "1.0.39", features = ["full"] }
在 lib.rs 中:
pub fn cmp(a: syn::Path, b: syn::Path) -> bool {
a == b
}
在 Rust 1.46.0 上编译会导致错误:
error[E0369]: binary operation `==` cannot be applied to type `syn::Path`
--> src/lib.rs:4:7
|
4 | a == b
| - ^^ - syn::Path
| |
| syn::Path
error: aborting due to previous error
syn::Path implements Eq/PartialEq with feature "full" or "derive":
use syn; // 1.0.33
fn cmp(a: syn::Path, b: syn::Path) -> bool {
a == b
}
我探索了 syn 的 PartialEq 和 Eq 特征实现在“完整”或“派生”功能门之后,但我仍然不知道。
明确尝试了 1.0.33 版,该版本在 Playground 中运行,在我的 PC 上结果相同。
我已经经历了将 async-trait 拆分并重新组合在一起的障碍,但这超出了我的技能范围。
- rustc 1.46.0 (04488afe3 2020-08-24)
- 货物 1.46.0 (149022b1d 2020-07-17)
cargo tree 使用 syn 进行新项目:
tmp v0.1.0 (/home/debian/Documents/Projects/tmp)
└── syn v1.0.39
├── proc-macro2 v1.0.19
│ └── unicode-xid v0.2.1
├── quote v1.0.7
│ └── proc-macro2 v1.0.19 (*)
└── unicode-xid v0.2.1
【问题讨论】:
标签: rust compiler-errors dependencies rust-cargo