crates/sub/Cargo.toml: default-features
is ignored for primitives, since default-features
was not specified for workspace.dependencies.primitives
, this could become a hard error in the future
警告 Cargo 工作区依赖管理规则 与 成员package
指定的依赖特性有覆盖冲突,未来的版本可能会由警告变为error。crates/sub package
的primitives 依赖的default-features
特性设置被工作区的primitives crate 设置覆盖、未生效。
rust 中虽然可使用workspace使项目内 成员package
继承workspace.dependencies中对于指定依赖的配置(如: 依赖的version,feature..),但继承dependencies配置时有1个需要注意的地方。
当在成员package
中设置某个crate的workspace为true时,继承的特性存在覆盖和附加2种方式。
如在workspace中配置tokio-stream 依赖如下
[workspace.dependencies]
tokio-stream = { version = "0.1.17", features = ["default", "sync"] }
成员package 中配置tokio-stream依赖为
[dependencies]
tokio-stream = { workspace=true, features = ["other"] }
成员package中 tokio-stream的最终设定为:
["default", "sync", "other"]
.
当在workspace中配置 tokio-stream = {version="0.1", default-features = false}
,default-features特性采用的覆盖规则,会覆盖成员 package中的default-features 特性
(如tokio-stream = {workspace, default-features = true}
),这个配置中的default-features
会被workspace设置覆盖不会生效。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有